Get a list of deleted files from rsync
I synchronise my music collection between:
- My desktop's RAID10, where I rip CDs and download music to, and
- The house media centre, which controls audio players around the house
I do this with a very simple, little rsync command:
rsync -av /media/ned/music/ tank:/media/steve/music/
Occasionally I'll delete something on my desktop, or rename it. When I sync again Tank keeps the old copy and this can result in duplicates.
I know there are --delete-{before/after}
options but I am very apprehensive about automatic deletions. There is no third backup yet, so if I make a mistake (which I have before) and rsync
nukes my "backup" on Tank, I've lost data.
Is there a way to generate a list of potential deletions after a transfer has finished? Ideally rsync
would present me the list and give me a [y/N]
prompt but I'm more than happy doing this in a separate command (I'll just write a syncmusic
script).
Solution 1:
Use the --dry-run
option.
rsync -av --delete --dry-run /media/ned/music/ tank:/media/steve/music/ | grep deleting
This prints a list of things rsync
would delete if you ran the command without the --dry-run
option.
Solution 2:
What you are actually looking for is:
rsync --dry-run --delete-after -av --info=DEL /media/ned/music/ tank:/media/steve/music/
If you want to check the progress as well then you can use:
rsync --dry-run --delete-after -av --info=DEL,PROGRESS2 /media/ned/music/ tank:/media/steve/music/