Backup retention using FTP backup

S2S-Robert

Verified User
Joined
Jun 24, 2003
Messages
415
Location
The Netherlands
If you're using daily ftp backup as a sysadmin you probably want to retain some of your backups, but likely not all of them. There's no good in saving each and every single day backup, so you might want to save only weekly / two weekly backups. At least I did.

In order to remove some of the backups, but retain others I've created a monthly cron script that saves every two weeks of backups. Perhaps you might be interested in it so I'll share it here. It's truly impossibly simple but hey, take it or leave it! :D

Requirements:

  • Ability to run monthly crons
  • Create a "current" and "old" directory in your FTP backup directory
  • Save DA backups to current
  • Set the DA backup to run after the time the monthly backups runs (otherwise you might mess up 01 & 15 backups)

Create a file in /etc/cron.monthly/

Code:
#!/bin/sh

mv /home/<user>/<backup dir>/current/*-01-* /home/<user>/<backup dir>/old/
mv /home/<user>/<backup dir>/current/*-15-* /home/<user>/<backup dir>/old/

rm -rf /home/<user>/<backup dir>/current/*

For more days of backup just add *-07-*, *-21-* etc. etc.
 
Last edited:
Back
Top