Patch submitted to add a "move-existing" functionality
devin.nate at cloudwerx.com
Thu Aug 11 09:20:53 MDT 2011
I've already created a case and submitted a patch in the rsync bugzilla:
I'm posting here to reach a wider audience.
The use case is one where rsync is being used to replicate files from a source to a destination, with the --remove-source-files flag being used. The files on the source are created sequentially, based on the file existing or not.
Essentially, software creates a files named 1.tif, 2.tif, 3.tif, and so on, based on the existance of the files. If rsync moves the files from the source to the destination, then the files 1.tif, 2.tif, 3.tif, etc., no longer exist on the source, so the software on the source re-starts it's numbering. Then, when rsync is run again either: (a) it'll sync the files up, which essentially means all prior data was lost, since they are totally different files, or (b) if --ignore-existing is used, the files back up on the source (good in that there's no data loss, bad that the files don't move).
The attached patch is a first attempt at adding a --move-existing functionality to rsync. It does not honour --dry-run and probably a ton of other use cases. It also uses strftime and some other functions which I see are in IFDEF blocks in other areas. The new filename generator should probably be in util.c, and its logging is ugly right now. It's not well documented (aka no man page entry).
It will rename a file in this format:
DEST POST RENAME: filename_2011-08-09-13-44-22-1.ext
It's somewhat contrary to rsync individual file sync, since it suggests we specifically don't want to sync a particular file. That said, it is in line with the concept of wanting to sync a (poorly) created series of files in a safe manner.
Information contained in this message may be privileged and confidential. If the reader of this message is not the intended recipient, be notified that any dissemination, distribution or copying of this communication is strictly prohibited. If this communication is received in error, please notify the sender immediately by replying to the message and deleting it from your computer. Thank you!
More information about the rsync