Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to run rsync on server A to copy all files from Server B when they are newer than 7 days.(find . -mtime -7)

I don't want to delete the files on Server B.

Thanks for you help.

share|improve this question

migrated from Jun 15 '11 at 1:53

This question came from our site for professional and enthusiast programmers.

b) how often do you run rsync? – phresnel Jun 14 '11 at 13:53
up vote 17 down vote accepted

This should get you underway in a solid way

rsync -RDa0P \
    --files-from=<(find sourcedir/./ -mtime -7 -print0) \
    . user@B:targetdir/

This copies device nodes, permissions, timestamps. I'm pretty sure the -H option won't be accurate with --files-from

share|improve this answer
To set that as a remote filter: rsync -avn --files-from=<(ssh user@A 'find /path/on/A/ -mtime -7 -type f -exec basename {} \;') user@A:/path/on/A/ user@B:targetdir – cybertoast Aug 22 '14 at 16:04

I wrote this script based on cybertoast's comment to sync from a remote server to local.

You can call the script with ./ 3 or ./ 3 dry for a dry run.


if [[ -z $TIME ]]; then
  echo "Error: no time argument."
  echo "Please enter the number of days to sync."
  exit 1

if [[ $DRYRUN = "dry" ]]; then
  echo "Dry run initiated..."

rsync -avz $DRYRUNCMD --files-from=<(ssh \
    user@remote "find path/to/data/ \
    -mtime -$TIME ! -name *.mkv -type f \
    -exec ls $(basename {}) \;") \
  user@remote:. .
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.