Backup with rsync until one month
jw at pegasys.ws
Wed Nov 26 09:58:45 EST 2003
On Tue, Nov 25, 2003 at 03:14:54PM +0100, Nazar Hassan wrote:
[reformatted -- please use shorter lines]
> I use rsync in the company to make a backup every 4 hours.
> but I would like to do in a way like this, that the rsync
> make a backup of the changed files until one month long.
> EX:- file.bak.001 file.bak.002 .....
> This file will be to get always, and so i can get the all
> files untill an one month old version of the file.
Current command lines and examples of before and after, both
current and desired would help immensely in understanding
what it is you are doing and what you want.
It sounds to me like you are using rsync every four hours to
make backups and you want to use the --backup option to
preserve the old versions of the files (what i call
At this time the backup files are being replaced the next
time the rsync runs and they never get removed.
If i understood you correctly the easiest thing to do exactly
that would be to specify a --suffix value to rsync that
included the date and hour of the backup. --suffix=`date
+.BAK.%y%m%d%H` might suffice. Then you could run a nightly
script that would find all the .BAK. files and compare their
date strings against LAST_MONTH=`date -d "-1 month"
+%y%m%d%H` for and rm them. This assumes you aren't using
the --backup-dir option which in a way makes this even
Unless there is a particular reason for having decrementals
you might be better off using --link-dest instead of
--backup. Mike Rubel has a writeup (out-of-date? translation
available on German wiki) that uses --link-dest for a 1 week
rotation but could be made into a 1 month rotation easily
enough. You could look into dirvish, there are others using
it to do backups every four hours and it does automatic
J.W. Schultz Pegasystems Technologies
email address: jw at pegasys.ws
Remember Cernan and Schmitt
More information about the rsync