Thursday, August 27, 2009

rsync a directory to another destination

I wanted to sync up a directory on one machine to another, but I only wanted to transfer missing files (not updated) and to have the transferred files written to another directory (so I could easily find them and perform another action on them). The following mammoth incantation does the job:


rsync --verbose  --progress --ignore-existing --stats --compress 
--rsh=/usr/bin/ssh --size-only --compare-dest='~/Music/iTunes/iTunes\ Music/'
--recursive ~/Music/iTunes/iTunes\ Music/* macmini.local:'~/Desktop/incoming-music'


This makes a bunch of empty directories (those that the --compare-dest contains but we don't write to), cleaning them up is as simple as:

find Desktop/incoming-music/ -type d -print0 | xargs -0 rmdir -p

No comments: