Rsync files younger or older than x days

https://www.nicovs.be/rsync-files-younger-or-older-than/

 

Finding files younger than 31 days is performed like this:

Rsyncing all files from a folder is pretty easy too:

Now, if you would like to rsync only the filers younger thn 31 days from your source folder, you can combine rsync and find in this way:

However… this is not 100 working as intended… This will skip filename with spaces, as the space are not escaped during the rsync…

The solution for this is to split the one liner above into 2 seperate commands again:

1) perform the find, and write the output to a tempfile:

2) perform the rsync with the –from-files parameter:

(do not forget the . in the command to declare a ‘source dir’)

Remark: When using relative paths, you could/should change the /path/to/folder to path/to/folder and put a . instead of a / in your rsync command
E.g. like this:

No Comments

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *