On Mon, 2008-09-22 at 15:43 +1000, [EMAIL PROTECTED] wrote:
> I am running the following command to backup a specific file from
> /tmp/BACKUPFILE which contains the name "Friday2008-09-19.bkf".
> 
> rsync -ah --delete --numeric-ids --stats --delete-excluded
> --files-from=/tmp/BACKUPFILE /var/data/shares/vmbackups/
> /mnt/usb_backup/SFSYDVS01/daily.0/VM/
> 
> The name in /tmp/BACKUPFILE changes each day for example when next run it
> will be "Monday2008-09-19.bkf" I use a script before running rsync to
> obtain the most recently modified file from /var/data/shares/vmbackups/ and
> cat it into /tmp/BACKUPFILE.
> 
> I want the /mnt/usb_backup/SFSYDVS01/daily.0/VM/ directory to only ever
> contain the most recent backup file e.g.
> 
> [EMAIL PROTECTED]:~# ls -t1 /var/data/shares/vmbackups | head -n 1 >
> /tmp/BACKUPFILE
> [EMAIL PROTECTED]:~# rsync [CORRECT OPTIONS] --files-from=/tmp/BACKUPFILE
> /var/data/shares/vmbackups/ /mnt/usb_backup/SFSYDVS01/daily.0/VM/
> [EMAIL PROTECTED]:~# ls /mnt/usb_backup/SFSYDVS01/daily.0/VM/
> Friday2008-09-19.bkf
> 
> Skip to next day.....
> 
> [EMAIL PROTECTED]:~# ls -t1 /var/data/shares/vmbackups | head -n 1 >
> /tmp/BACKUPFILE
> [EMAIL PROTECTED]:~# rsync [CORRECT OPTIONS] --files-from=/tmp/BACKUPFILE
> /var/data/shares/vmbackups/ /mnt/usb_backup/SFSYDVS01/daily.0/VM/
> [EMAIL PROTECTED]:~# ls /mnt/usb_backup/SFSYDVS01/daily.0/VM/
> Monday2008-09-19.bkf
> 
> But currently the command grabs everything in /var/data/shares/vmbackups/
> and so I end up with:
> 
> [EMAIL PROTECTED]:~# ls /mnt/usb_backup/SFSYDVS01/daily.0/VM/
> Monday2008-09-19.bkf Friday2008-09-19.bkf
> 
> I expected the --delete option would have removed Friday2008-09-19.bkf in
> this example (with the --delete option) but it doesn't.  I've read the man
> page and googled a bit but I think i'm getting a bit lost.

The current meaning of --files-from is to restrict rsync to processing
the paths in the list, and rsync deletes extraneous destination files as
part of the processing of the parent directory (assuming -d or -r is
on), so you can't delete unlisted files this way.  See:

https://bugzilla.samba.org/show_bug.cgi?id=3465

Try this instead:

rsync [OPTIONS] --include-from=/tmp/BACKUPFILE --exclude='*'
/var/data/shares/vmbackups/ /mnt/usb_backup/SFSYDVS01/daily.0/VM/

This way, rsync will scan the destination directory for deletions (since
you have -a without --files-from, which implies -r) and will delete the
old files because they are excluded with --delete-excluded.

Matt

-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to