Is there a way to auto-rename an existing file on the receiver? For example: if filename
already exists, it auto-rename filename
to something like filename_001
, filename_002
and so on....
So far all I have is this:
$ rsync -rh --progress --stats --exclude '.thumb' \
--update --perms /origin /destination
By the way, I know rsync has --ignore-existing
to "skip updating files that exist on receiver", but I guess what I need would be something like --rename-existing
.
If you are looking to keep incremental versions of a data set (without using version control such as the git suggestion which would be the other alternate way to do this) consider using
rsnap
instead ofrsync
.It will allow you to take snapshots of a folder or set of files so that you could restore what the whole thing as it was at any given point in time. Instead of saving multiple copies of whole files it should only save the differences between them, saving you the space of having all those duplicates around.
Since it uses rsync to copy the files behind the scenes, you can append rsync options to the end of the command. For example in your situation to keep ten backup copies you could do something like this:
There are the
--backup
and--suffix
options (at least in v3.0.8) but they don't quite accomplish what you want because--suffix
is fixed and not auto-incrementing (cp
has a nice auto-incrementing backup suffix option). The best I could come up with was using a datetimestamp as the suffix like so:I would also look into using git which is an open-source version control software. There's a bit of a learning curve to it, but it sounds like it would be appropriate for what you're trying to do. It also uses ssh, ftp and some other transfer protocols. A good tool for mirroring repositories, tracking changes, etc. It also has great documentation and a very active irc channel (webchat.freenode.net #git)if you get stuck.
Good luck!