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

James Robertson j at mesrobertson.com
Wed Sep 24 05:41:41 GMT 2008


Matt McCutchen wrote:
> On Wed, 2008-09-24 at 13:00 +1000, James Robertson wrote:
>   
>> I tried this but it doesn't seem to work for me as you describe.  I just 
>> created a test setup.  The commands I'm running are as follows:
>>
>> root at sfnas01:~# rsync --version
>> rsync  version 2.6.9  protocol version 29
>> root at sfnas01:~# ls /tmp/source/
>> Thursday2008-09-11.bkf  Tuesday2008-09-09.bkf  Wednesday2008-09-10.bkf
>> root at sfnas01:~# ls -t1 /tmp/source | head -n 1 > /tmp/BACKUPFILE
>> root at sfnas01:~# cat /tmp/BACKUPFILE
>> Thursday2008-09-11.bkf
>> root at sfnas01:~# rsync -ah --delete --numeric-ids --stats 
>> --delete-excluded -include-from=/tmp/BACKUPFILE --exclude='*' 
>> /tmp/source/ /tmp/destination/
>> .d..t...... ./
>>
>> Number of files: 1
>> Number of files transferred: 0
>> Total file size: 0 bytes
>> Total transferred file size: 0 bytes
>> Literal data: 0 bytes
>> Matched data: 0 bytes
>> File list size: 20
>> File list generation time: 0.001 seconds
>> File list transfer time: 0.000 seconds
>> Total bytes sent: 42
>> Total bytes received: 26
>>
>> sent 42 bytes  received 26 bytes  136.00 bytes/sec
>> total size is 0  speedup is 0.00
>> root at sfnas01:~# ls /tmp/destination/
>> root at sfnas01:~#
>>     
>
> The -include-from=/tmp/BACKUPFILE is short a dash, causing it to be
> parsed as -i -n -c -l -u -d --rsh=-from=/tmp/BACKUPFILE .  Change it to
> --include-from=/tmp/BACKUPFILE .
>
> Matt
>
>   
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 guys running the backup to /var/data/shares/vmbackups/ 
are considering copying the files direct rather than sticking it into a 
*.bkf and have it create folders like 1/, 2/, 3/ with files and folders 
under that.

I came up with running this:

root at sfnas01:~# ls /tmp/source/
1/  2/  3/
root at sfnas01:~# ls -t1 /tmp/source/ | head -n 1 > /tmp/BACKUPFILE
root at sfnas01:~# cat /tmp/BACKUPFILE
3/
root at sfnas01:~# ls -t1 /tmp/source/ | grep -f /tmp/BACKUPFILE -v > 
/tmp/BACKUPEXCLUDE
root at sfnas01:~# cat /tmp/BACKUPEXCLUDE
2/
1/
root at sfnas01:~# rsync -ah --numeric-ids --stats --delete-excluded 
--include-from=/tmp/BACKUPFILE --exclude-from=/tmp/BACKUPEXCLUDE 
/tmp/source/ /tmp/destination/
root at sfnas01:~# ls /tmp/destination/
3/

Which works and copies the subdirectories and files but is there a more 
elegant solution without the need for the /tmp/BACKUPEXCLUDE file?

I think i'll rename /tmp/BACKUPFILE to /tmp/BACKUPDIR :)

Apologies as they only just decided this today after I came back with 
the solution you helped me with.







More information about the rsync mailing list