--delete-before doesn't seem to actually be deleting before transfer

Matt McCutchen matt at mattmccutchen.net
Tue Jul 14 21:50:41 MDT 2009


On Tue, 2009-07-14 at 13:01 +0200, Tim Edwards wrote: 
> I have a script transferring some backup files onto a USB stick, which
> has limited space. I use rsync 3.0.5 with the following command:
> rsync -av --delete-before /local/backups/dir/backup1_todaysdate
> /local/backups/dir/backup2_todaysdate
> /local/backups/dir/backup3_todaysdate /USBstick/backups/dir
> 
> The USB stick runs out of space if more than 1 backup set is put on it,
> so I'd assumed that by using the --delete-before option would first
> scrub /USBstick/backups/dir of any files that I hadn't listed to be
> transfered - is this how it works?

No, rsync will only do that if if you have it
"synchronize" /USBstick/backups/dir , i.e., specify a source directory
that maps to it.  Just copying several dirs _into_ /USBstick/backups/dir
does not do the trick.  See the description of --delete in the man page.

Something like the following, copying the entire /local/backups/dir but
excluding all the backups except those you want, would work:

rsync -av --delete-before --include=/backup1_todaysdate
--include=/backup2_todaysdate --include=/backup3_todaysdate
--exclude='/*' /local/backups/dir/ /USBstick/backups/dir

-- 
Matt



More information about the rsync mailing list