rsync with --backup

Matt McCutchen matt at mattmccutchen.net
Thu Sep 4 16:01:42 GMT 2008


On Thu, 2008-09-04 at 13:46 +0300, Paul -Spawn- Rysevets wrote: 
> here is the deal: we have an ant-script.. that uses rsync to
> update our server's files.. i.e. patch-script
>    and request is.. to save files, that are updated...
>    and when the patch-script is run again (like, the same one)
> back-ups must not be overwritten.
> 
>    in rsync i've found --backup and --backup-dir...
>    but the thing is.. that i need to store backups on local station
> (it is simplier to me),
> not on the receiving side... (as backup-dir option tries to do)
> 
>    giving --filter='Pp *~' after --backup-dir gives me
>    --filter=Pp *~: unknown option

Rsync 2.6.3 is too old to understand that option, but in any event, it
would only protect backups from deletion, not from overwriting if the
same destination file is updated again.

> and
>    --backup-dir='user at host1:/path/to/backupdir/' /local/path/ user at host2:/remote/path/
>    gives no results.. files are updated, but no backups .. ("user"
> are the same on both servers)

You have to pass --backup too.  --backup-dir does not by itself enable
backups; it only modifies the behavior of backups.  In addition,
--backup-dir only supports a directory on the receiver; it cannot send
backups back to the sender.

> i could try to store back ups on host2, then tar them and the copy
> them back to host1...

This is what I would do, except I would use rsync instead of tar to pull
the backups.  For example:

DATE=$(date +%Y%m%d)
rsync -a --backup --backup-dir=/remote/backups/$DATE/ \
	/local/path/ user at host2:/remote/path/
rsync -a user at host2:/remote/backups/$DATE/ /local/backups/$DATE/

> or at first rsync modified file between two hosts to host1 (i.e. make
> backup manually)
> and then rsync to host2

That would also work.  If you like, you could have the second run apply
a batch file written by the first run instead of rereading the source.

Matt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/rsync/attachments/20080904/a53854dc/attachment.bin


More information about the rsync mailing list