tags:

views:

265

answers:

3

The proprietary software that we're using for backups (sadface) generates a series of images that we use rsync to sync over to an off-site location. The files generated look something like:

a.bak
b.bak
c.bak

So we sync those across and get exactly the same structure on the off-site machine. Then the backup program runs again and we get something like:

archive/a.bak
archive/b.bak
c.bak
d.bak
e.bak

So the rsync job runs and we end up with something like:

archive/a.bak
archive/b.bak
a.bak
b.bak
c.bak
d.bak
e.bak

Obviously, we would prefer the off-site machine to look like the on-site machine does, to avoid clutter and save on storage space. Is there any way to get rsync to mirror the moves that have happened on-site, or are we going to have to work out something outside of rsync?

+1  A: 

I don't know of any way to have it intelligently detect that the file has simply "moved". You can, however, use the --delete flag, so that it'll delete files from the destination that no longer exist on the source. The downside is that you'll re-copy the file whenever it moves, but at least you won't be wasting space for the old location on the destination anymore.

Laurence Gonsalves
Rsync cannot detect moved files, since it doesn't maintain any state on either source or target.
JesperE
`--delete-after` is a good idea, also consider using `--link-dest`
Hasturkun
The data on the filesystem is all the state it would need. Rsync can already detect if content moves around within a file and handle that efficiently. (search for "rsync algorithm") I don't see why that couldn't be generalized to work across files in some future version of rsync.
Laurence Gonsalves
A: 

If you use the --times switch and make sure both ends have clock syncing and then you can use --update and --delete options to only transfer newer files and prune away files that shouldn't be there.

See the rsync man page for full options.

JBRWilkinson
A: 

The solution we ended up going with was to write a script that works out the moves itself.

Daniel Watkins