I'm am attempting to write a script that will copy files created in the last 24 hours AND be of a specific file-type (*.png).
The command I have tried is:
rsync -avz --ignore-existing --include='*.png' --exclude='*' \
--files-from=<(ssh user@remote1 'find /home/admin/Backup/ -mtime -1 -type f -exec basename {} \;') \
user@remote1:/home/admin/Backup/ /Repository/
This works for *.png files in the Backup directory however the command fails when the files are two or three folders deep i.e. located in /home/admin/Backup/folder1/folder2/
The error I get is
link_stat '/home/admin/Backup/example.png' failed: No such file or directory (2)
That is because basename {}
is chopping off the location when it returns the result to rsync
. So I tried removing basename {}
and I get this:
link_stat '/home/admin/Backup/home/admin/Backup/folder1/folder2/example.png' failed: No such file or directory (2)
It's like rsync
is appending the source directory and I don't know how to fix it. Anybody know how to fix this or perhaps I am just going about pulling this file off the remote server the wrong way?
find
allow use-printf "%P\n"
instead-exec basename {} \;
?