0

I've got the following command to try to sync only files less than about 36 hours old (2200 minutes):

sudo su -c "rsync -vrt --delete --rsync-path='sudo rsync' --files-from=<(find '/home/dir1' -mmin -2200 -exec basename {} \;)  '/home/dir1'  Maildir"

It works except it's bringing over all the files in some of the subdirectories even if they are older the 36 hours. This is because those subdirectories are younger than 36 hours.

So I modified the find commmand in --files-from to this:

find '/home/dir1' -type f -mmin -2200 -exec basename {} \;

Now I have a new problem. It cannot save the files and fails with many of these errors:

rsync: link_stat "/home/dir1/new/blah" failed: No such file or directory (2)

Is there a way to fix this besides doing one rsync to create the directories and then another to bring the files over?

2
  • You should change the title so that it relates your actual current problem. Maybe this will help: stackoverflow.com/questions/1636889/… Feb 28, 2021 at 0:41
  • Well, I'm trying to show what I did to try to fix the original problem. Maybe there is a different approach then what I tried.
    – StevieD
    Feb 28, 2021 at 0:42

1 Answer 1

1

OK, after fiddling with this and patching together different suggestions from elsewhere, I came up with this:

sudo su -c "rsync -vrt --delete --from0 --files-from=<(cd /home/dir; find . -type f -mmin -2200 -print0 )  '/home/dir1'  Maildir"

This will cd into the source directory first before running the find command. I also use -print0 argument to the find command instead of -exec basename {} and add a --from0 argument to rsync which allow it to parse the null-character-terminated output of the find command.

2
  • 1
    There's a ; missing before find and --print0 should be -print0. I believe you can also remove option --rsync-path.
    – Freddy
    Feb 28, 2021 at 1:53
  • Fixed. The --rsync-path option can be removed in this case where the transfer is happening on the same machine, yes. Might be needed if you are running a similar command to this on a remote machine.
    – StevieD
    Feb 28, 2021 at 10:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .