1

I have strange rsync behaviour. I need to copy all files youngest than 2 days from one folder to another.

So i've mixed rsync with files-from argument and find utility in a script to do what i need to do.

#!/bin/bash
cd /mnt/smb/online/
find . -mtime -2 -print > /tmp/rsynclist
rsync -av --ignore-existing --size-only --files-from=/tmp/rsynclist /mnt/smb/online /mnt/backup/

File /tmp/rsynclist is ok, and have only files that i need (all files not older than 2 days). But rsync seems to ignore that 'files-from' argument and continuing to copy all files from source older.

Where i am mistaking?

3

The problem is not in the rsync command, but in your find. While testing your script I noticed that there are also directories in my rsynclistfile that have been changed, resulting in rsync copying all files under these directories.

To prevent this, add -type f to your find command.

#!/bin/bash
cd /mnt/smb/online/
find . -type f -mtime -2 -print > /tmp/rsynclist
rsync -av --ignore-existing --size-only --files-from=/tmp/rsynclist /mnt/smb/online /mnt/backup/

Afterwards only paths to files should be in the list, giving in the intended result.

-2

The syntaxe of the rsync command is :

rsync [option] source[x] destination

You had put 2 sources :

  • /tmp/rsynclist ; the right one
  • /mnt/smb/online ; this is wrong and you must delete it

try with :

rsync -av --ignore-existing --size-only --files-from=/tmp/rsynclist  /mnt/backup/
  • This will in rsync complaining that a parameter is missing. – Gerald Schneider Jun 21 '17 at 8:19
  • 1
    files-from is not source folder, it just list of files that rsync need to copy. So source parameter will be missing. – Jaels Jun 21 '17 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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