[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Script to manage backups with Tarsnap -



All - 	
I don't know if this will be helpful to anyone else but I needed a script to delete old backups and manage my snapshots so I wrote this -

http://github.com/Gestas/Tarsnap-generations

Some more details are below. I'm still testing so be aware that you may need to check back for a newer version soon, but this seems to be working for now. If you would like to see something added or changed please let me know and I will get to it when I can.

--Craig

NAME
  tarsnap-generations -- Manages Tarsnap backups

SYNOPSIS
  tarsnap-generations

  ARGUMENTS:
           ?   Display this help.
-f Path to a file with a list of folders to be backed up. List should be \n delimited.
          -h   Number of hourly backups to retain.
          -d   Number of daily backups to retain.
          -w   Number of weekly backups to retain.
          -m   Number of monthly backups to retain.

DESCRIPTION

The script is designed to be run via crontab. It expects five inputs and a .tarsnaprc file (see below). If you don't want to take hourly backups then use crontab to schedule backup only in the hour specified in the script as the $DAILY_TIME variable, line 9. Set -h to "1". By default the script takes the "DAILY" backup in the 23:00 hour system time.

REQUIRES
  The script requires a .tarsnaprc that specifies at least these options;
    keyfile <path to keyfile>
    cachedir <path to cache dir>
    exclude <path to cache dir>
    humanize-numbers

CRONTAB EXAMPLE

15 * * * * tarsnap-generations.sh -f /root/tarsnap.folders -h 36 -d 30 -w 12 -m 24 << Takes a backup every hour at the :15, keeps 36 hours of hourly backup, 30 days of daily backups, 12 weeks of weekly backups and 2 years of monthly backups.

30 23 * * * tarsnap-generations.sh -f /root/tarsnap.folders -h 1 -d 10 -w 4 -m 2 << No hourly backups, daily backup at 23:30, keep 10 days of daily backups, 4 weeks of weekly backups and 2 months of monthly backups. Note that the hour here (23) must match the hour set by $DAILY_TIME, line 9 of the script. 23 (11PM) is the default.

ERRORS
The script will exit with a non 0 error code if a backup fails or can't be verified. Be sure to pay attention.

AUTHOR
  craig@gestas.net

WITH THANKS TO

http://www.bluebottle.net.au/blog/2009/tarsnap-backups-on-windows-and-linux
http://tarsnap.com
http://en.wikipedia.org/wiki/Grandfather-father-son_backup