Need some kind of software (Debian) to create backups. Generally have few folders, with ~10k files, total zip size ~5Gb. Want create 7 backups max. i.e. - delete oldest one every day.

i.e. need folder with 7 yyyy-mm-dd.tar.gz files inside with last archives. I Am sure that exist some kind of standard console software for automate this?

  • 1
    OT: who did invent the word 'soft' ? It strikes me as absurd that so many askers say 'I have a soft' or 'I need a soft'. You need a program or an application. Not a thing that doesn't exist and has strange connotations – sehe Jun 18 '11 at 15:20
  • 1
    +1 @sehe , it even looks and sounds horrible. @softm, you may want to take a look at rdiffbackup, it's documentation and example pages are really usefull. It's so easy to create something custom and use it along with cron. – Ivan c00kiemon5ter V Kanak Jun 18 '11 at 15:57

As you say there are sure lots of standard software to do this. I'm using a self built shell script for the purpose for now. In the future I'll migrate it to Perl to signal success and failures in a dashboard. I've already implemented a similar concept for MySQL backups of six servers, they update the status in Amazon SimpleDB and I've a dashboard to check the status.

Here is my script:


HOSTNAME=MYHOSTNAME                               # name of this computer
DIRECTORIES="/var/www /etc/ /var/backup/database" # directories to backup
BACKUPDIR=/mnt/backup                             # where to store the backups
TIMEDIR=/mnt/backup/last-full                     # where to store time of full backup
TAR=/bin/tar                                      # name and location of tar

DOW=`date +%a`                          # Day of the week e.g. Mon
DOM=`date +%d`                          # Date of the Month e.g. 27
DM=`date +%d%b%Y`                       # Date and Month e.g. 27Sep2010

# On the 6 of the month a permanent full backup is made
# Every Sunday a full backup is made - overwriting last Sundays backup
# The rest of the time an incremental backup is made. Each incremental
# backup overwrites last week incremental backup of the same name.
# if NEWER = "", then tar backs up all files in the directories
# otherwise it backs up files newer than the NEWER date. NEWER
# gets its date from the file written every Sunday.

# Monthly full backup
if [ $DOM = "06" ]; then

# Weekly full backup
if [ $DOW = "Sun" ]; then
    NOW=`date +%d-%b`

    # Update full backup date
    echo $NOW > $TIMEDIR/$HOSTNAME-full-date

# Make incremental backup - overwrite last weeks

    # Get date of last full backup
    NEWER="--newer `cat $TIMEDIR/$HOSTNAME-full-date`"
  • So your never clean up old backups? – softm Jun 18 '11 at 15:35
  • It's not my responsibility, because they are sent to another server and archived from there by another sysadm. Anyway an easy way to keep only 7 copies is use the Day of the Week only in the file name. As you can notice from my script the full monthly backup uses the full date, while all the other backups use only the day of the week, so they will get overwritten after a week. Alternatively you can use find /backupdir -mtime +7 -name '*.tar' -exec rm {} \; – stivlo Jun 18 '11 at 15:42

It is better to use rsync for this kind of backup job. Rsync is tailor made utility for this, it can take incremental backups comparing previous and new backups.

If you want you can combine rsync with logrotate.

  • +1 for rsync. Use with cron for added utility. – Lukasa Jun 18 '11 at 19:31

I am a fan of hardlink-based full-backups, since in most applications they consume only little more space than incremental backups, but still offer the full luxury of full-backups.

A tool to automate hardlink-based backups is rsnapshot, which is based on rsync. You can also directly use rsync with the --link-dest switch to enable linking against a previous backup for unchanged files. rsnapshot however offers you all the meta functionality around (keeping n many backups, deleting old ones etc).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy