rsync equivalent to mv --backup=numbered
Dear LQ,
How do you rsync files to remote location AND save a backup copy of overwritten files ? I was hoping to find something similar to mv's --backup=numbered version. The end result on the target host would look like : file.1 file.2 file.3 |
From the rsync manual page:
Quote:
|
Not the function of rsync. A simple search should have turned up rsnapshot or its contemporaries.
|
Taking a slightly lateral approach, it looks a bit like you want a different backup for eg each day ?
In which case, use target dirs named for each day (or date etc), which means you'd always have a 'few' backups/originals. It really depends on the exact effect you are after; keep 2 systems in sync+backups, or just backups... |
+1 for rsnapshot...an easy to configure wrapper for rsync to create/maintain multi-generational backups.
|
Quote:
|
Quote:
Quote:
|
So why not just use cp? You could write a script, or just put the entire statement in the crontab. I think a script would be preferable. Get the day of the week, use that as a variable to choose the folder to receive the cp.
|
'cp' just works locally (unless you pipe through netcat / nc ?).
Apart from that though, yes - grab the day name from the date cmd and write a script for cron to call. Otoh, if you literally just want to backup some files from A to B, and overwrite previous copies (without disturbing B copy of the files), then the above sans the 'day' bit. Just designate a dir on B to save A's files and rsync or whatever to there. You could even mount the dir on B onto A and use a 'local' cp ;) If you want secure, see sshfs :) PS I'm assuming the machines are 'close enough' that remote mounting is practical (think timeouts on long distance cxns) . |
Thank you all folks, the easiest would be to use rsync --backup-dir, but if I take only the "day" portion of it that means I can only have a single backup per day. Anyway, marking this as solved.
|
If you want to back up more often than once per day, there are ways to do that. You could do it hourly and have a directory for each hour. You can get the hour of the day easily enough. Or just name the directory with a number which rotates between 1 and the number of backups you want. 1.1, 1.2, etc. It depends on the frequency of backups, and the number you want to keep.
|
Quote:
|
All times are GMT -5. The time now is 08:02 PM. |