0

rsync is pretty clear to me but I have a specific task I could not figure out yet.

I want to sync source with destination 1:1. I believe the --delete option would cover that. So if I add a file on source, rsync would add the file to destination. If the file is removed on source, rsync removes it on destination. Now, I do not want the destination file to be removed but to be moved to an "archive" folder.

Is it possible to ask rsync for a list of missing files on source? So I can move the items on the list from destination to archive?

I have a solution that kind-of-works but it is not stable since it relates on a transfer file and depends on rsync console output which might differ in rsync versions. rsync -avun --delete src/ tgt/ |grep "deleting" | cut -c10- > transfer.txt rsync --files-from=transfer.txt --remove-source-files tgt/ archive/ rm transfer.txt rsync -ravu --delete src/ tgt/ any ideas on how to do this in a more reliable way?

2

The --backup --backup-dir=/some/backup/directory options will backup files that are changed or deleted on the destination.

rsync -auv --delete --backup --backup-dir=/path/to/backupdir src/ tgt/

Note that the path for --backup-dir is relative to the destination, so to avoid it being placed inside tgt/ it is best to provide an absolute path.

  • this really is a great solution for this problem. Thank you so much! – mark Sep 5 '15 at 23:24
1

There is the option --list-only option.

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.