--files-from= and --delete corrent options

Matt McCutchen matt at mattmccutchen.net
Wed Sep 24 20:33:44 GMT 2008


On Wed, 2008-09-24 at 15:41 +1000, James Robertson wrote:
> >> root at sfnas01:~# rsync -ah --delete --numeric-ids --stats 
> >> --delete-excluded -include-from=/tmp/BACKUPFILE --exclude='*' 
> >> /tmp/source/ /tmp/destination/

> If /tmp/BACKUPFILE contained a directory e.g.
> 
> root at sfnas01:~# cat /tmp/BACKUPFILE
> 3/
> 
> How would I get it to copy everything under and including 
> /var/data/shares/vmbackups/3/? and delete everything else on the 
> destination?

The exclude just needs to be anchored so that it matches only the
undesired top-level directories, not files inside the desired top-level
directory /var/data/shares/vmbackups/3:

rsync -ah --delete --numeric-ids --stats --delete-excluded
--include-from=/tmp/BACKUPFILE --exclude='/*'
/var/data/shares/vmbackups/ DEST/

The --include-from pattern will match any descendants
of /var/data/shares/vmbackups/3 that also happen to be directories named
3, but that should not hurt anything.  If you feel like being
meticulous, you could anchor that one too:

ls -t1 /var/data/shares/vmbackups/ | head -n 1 | sed 's,^,/,' >/tmp/BACKUPFILE

Matt



More information about the rsync mailing list