I have a scenario where I am copying from a local system to remote target and need to remove the local source files once they have been successfully transfered. --remove-source-files works fine for this. An issue has come up in that I need to be able to backup the removed local source files as well. With rsync 2.6.9 I tried: rsync --remove-source-files --backup-dir=/archive –abv (source) (remotehost:target) The result was that the backup files were made in /archive on the remotehost system and not the local system (where the original files were removed). Is this a bug or is the backup option only able to backup deleted target files? Is there another way around this? Note: As a WAG, I tried using a myhost:/archive (where myhost is my source host) type of entry for --backup-dir, but that just created a myhost: directory on the remotehost:target directory. Like I said, it was a WAG. Thanks, -Scott
On 5/4/07, ScottZ <mylists@pinesalad.net> wrote:> Is this a bug or is the backup option only able to backup deleted target files?The latter: --backup only backs up files deleted from the target.> Is there another way around this?Essentially you want to move each source file to another directory after it is successfully transferred. I'm sure there's a way to accomplish this, but it might not be simple. I'll tell you if I find one. Matt
> Essentially you want to move each source file to another directory > after it is successfully transferred.Exactly.> I'm sure there's a way to accomplish this, but it might not be > simple. I'll tell you if I find one.Thanks for looking at this Matt.
On 5/4/07, ScottZ <mylists@pinesalad.net> wrote:> --remove-source-files works fine for this. > > An issue has come up in that I need to be able to backup the removed local source files as well.I think the simplest way to accomplish this is to make a modified version of rsync that supports backing up removed source files. In fact, I did. The attached patch to rsync 2.6.9 adds a --source-backup option that backs up removed source files. You can compile and use your own copy of rsync that includes this patch. In case you're not familiar with compiling patched software, here are the steps: 1. Save the attached rsync-2.6.9-source-backup.diff somewhere. 2. Download and extract the rsync source package http://rsync.samba.org/ftp/rsync/rsync-2.6.9.tar.gz somewhere. 3. At the command line, cd into the extracted directory "rsync-2.6.9". 4. To apply the patch, run (substituting the actual place you saved the patch): patch -p1 <path/to/rsync-2.6.9-source-backup.diff 5. To compile rsync, run: ./configure make That makes an rsync executable in the current directory. You can run it from there or copy it to a directory on your $PATH. Matt -------------- next part -------------- A non-text attachment was scrubbed... Name: rsync-2.6.9-source-backup.diff Type: text/x-patch Size: 4384 bytes Desc: not available Url : http://lists.samba.org/archive/rsync/attachments/20070506/ae8324e7/rsync-2.6.9-source-backup.bin
On 5/6/07, Matt McCutchen <hashproduct+rsync@gmail.com> wrote:> The attached patch to rsync 2.6.9 adds a --source-backup > option that backs up removed source files.Oops, I made a typo in the addition to the man page. The fixed patch is attached. Matt -------------- next part -------------- A non-text attachment was scrubbed... Name: rsync-2.6.9-source-backup.diff Type: text/x-patch Size: 4383 bytes Desc: not available Url : http://lists.samba.org/archive/rsync/attachments/20070506/27b84253/rsync-2.6.9-source-backup.bin
Many, Many Thanks for this Matt! Seems to be working great so far. Just one question though. My initial tests with --backup-dir and -b had just the file being backed up to the specified dir. With --source-backup the tree structure of the original source file is also being included in the --backup-dir directory. example: rsync --remove-source-files --source-backup --backup-dir=/arc -av /home/dir/file remotehost:/dir/file results in the backup file being put in /arc/home/dir/file instead of /arc/file. It isn't a problem for me as my tree structure is limited to just a couple of directories, but could be a problem for those with a deeper one. Or am I not specifying something correctly? Again, many thanks for this. -Scott> -------- Original Message -------- > Subject: Re: Using --remove-source-files with backup? > From: "Matt McCutchen" <hashproduct+rsync@gmail.com> > Date: Sun, May 06, 2007 6:38 am > To: ScottZ <mylists@pinesalad.net> > Cc: rsync@lists.samba.org > > On 5/6/07, Matt McCutchen <hashproduct+rsync@gmail.com> wrote: > > The attached patch to rsync 2.6.9 adds a --source-backup > > option that backs up removed source files. > > Oops, I made a typo in the addition to the man page. The fixed patch > is attached. > > Matt