Rsync backup keep deleted files

backuprsync

I have to backup a set of userdata with rsync. There is just one little thing I cant figure out how to do.
When a user deletes a file it is kept on the server. This is fine since it might have been deleted by mistake, but it would be nice if it did not stay there forever.

So how do I make rsync delete files on DEST when they have not been precent on SRC for a certain amount of time (say, 7 days)

I know that I could just write a script that manually uses rsync on each file in the folder and then determines if the file on DEST should be deleted, but it would be kind of dumb to do this just to learn later on that rsync has this feature already. I cant find it though.

Many thanks for you time

Best Answer

Rsync won't do this on its own. Something like rsnapshot will let you maintain multiple generations of rsync-based backups (hourly, daily, monthly, etc) such that you can retrieve an accidently-deleted file. By using hard links, rsnapshot lets you keep a number of snapshots laying around without using a lot more space than the "cost" of a full backup.

There are other solutions out there that do the same thing-- rsnapshot just happens to be one I have personal experience with. (I highly recommend using the "sync_first" option if you do decide to use it...)

Related Topic