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?