[RSync] Re: How to delete files older than X on backup during sync?

Ashley M. Kirchner ashley at pcraft.com
Mon Nov 10 06:57:29 GMT 2008

Henri S wrote:
> You could find these files using find. Then, copy these to another
> directory and sycn the directory which has only the new files.
> If you were cleaver you could hard link the files to save space before the
> sync. But maybe someone on this list will know how to do this with just
> rsync.
> This is just one possiblity. Maybe somone has already written a tool to do
> the first step.
    This is rather similar to what I'm currently doing via a (shell) 
script which uses rsync.  I have several servers that get backed up 
every night, using a combination of hard links and multi-day retention.  
Basically, let's say I want to keep a 7 day backup on a server, the 
nightly process runs as follows:

    1. delete the oldest backup (.7)
    2. Increment all the other backups +1
       (.6 -> .7, .5 -> .6, .4 -> .5, .3 -> .4, and .2 -> .3)
    3. Create a hard link between .1 -> .2
    4. Run rsync from the source into .1

    So if a file disappears from the source, it still exists in backup 
for another 6 days after that night's backup.  After that, it gets deleted.

    This process allows me to backup 15 different servers to one single 
terabyte drive and keep 4 weeks worth of backup for each.  (NOTE: I'm 
not backing up 100% of each server's content, just things like /etc, 
/home, /var/www, /var/mail and the like.)

H | It's not a bug - it's an undocumented feature.
  Ashley M. Kirchner <mailto:ashley at pcraft.com>   .   303.442.6410 x130
  IT Director / SysAdmin / Websmith             .     800.441.3873 x130
  Photo Craft Imaging                       .     3550 Arapahoe Ave. #6
  http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A. 

More information about the rsync mailing list