BackupPC-users

Re: [BackupPC-users] Strict backup schedule

2010-01-31 21:04:51
Subject: Re: [BackupPC-users] Strict backup schedule
From: Gerald Brandt <gbr AT majentis DOT com>
To: "General list for user discussion, questions and support" <backuppc-users AT lists.sourceforge DOT net>
Date: Sun, 31 Jan 2010 20:05:16 -0600 (CST)

----- "Gerald Brandt" <gbr AT majentis DOT com> wrote:
> Hi,
>
> I have a situation where I need a 'strict' backup schedule.
>
> Our accounting data must be backed up daily, with weekly fulls on Friday and Monthly fulls on the last day of the month. Have mid-week and every 4 week fulls could mean we lose data. For example, if BackupPC does a weekly full on December 29, that means the next weekly full is January 5th. When the dailies get expired, it would be impossible for us to restore the last 2 days of December.
>
> In this particular case, we need a backup that is calendar driven, and not driven by BackupPC's concept of 7 days weeks, 4 weeks in a month, etc.
>
> My current backup is:
>
> $Conf{FullKeepCnt} = [4, 0, 13, 0, 0, 100];
>
> How can I change that (coupled with cron, I assume) so that at the end of the year, I have 12 monthly backups, all on the last day of the month, and the yearly on the last day of the year?
>
> I really never thought BackupPC's concept of days/weeks/months would be a problem, but now that I think of it, it can be.
>
> Gerald
>

It looks like this is working for me.  I have scripts in place and am testing them now. 

I basically did everything in bash scripts (since my perl sucks more than my bash scripts).  I would've done it in C++, but I wanted the scripts to be very universal. 

The difficult part was deleting old backups.  Basically, I told BackupPC to delete incrementals as per normal, and I set my FullKeepCnt to 2000.  That way, BackupPC itself should never delete any full backups.  I then wrote a script that deletes weekly backups older than 10 weeks, unless they land on the last day of the month.  I delete monthlys after 15 months, unless thay land on the last day of the year, and I delete yearlys after 4 years.

My bash scripting skills aren't very good, but the scripts are below for all to see.  Actually, I think I'll attach 'prune_backups.sh' instead of paste it in here, it's a bit large.  If you don't get the attachment and want to see the script, let me know.

If you see any errors or possible improvements, please let me know!

Gerald


This is my crontab:


#
# BackupPC : force full backups on Fridays
30 18 * * 5 backuppc /root/backuppc/friday_backups

# BackupPC : force full backups on last day of month
50 18 * * * backuppc /root/backuppc/lastmonthday_backups

# BackupPC : prune full backups on Sundays
0  13 * * 0 backuppc /root/backuppc/prune_backups.sh


These are my scripts:

friday_backups:

#!/bin/bash

# force all hosts in the host file do have a full backup on Friday
# unless that Friday is the last day of the month
if [ ! $(cal | tr -s '[:blank:]' '\n' |tail -1) = $(date +%d) ]
then
  for HOST in $(cat /etc/backuppc/hosts | grep ^[A-Za-z0-9] | grep -v host | awk '{print $1}')
  do
    /usr/share/backuppc/bin/BackupPC_serverMesg backup ${HOST} ${HOST} backuppc 1
#   echo ${HOST}
  done
done


lastmonthday_backups:

#!/bin/bash

# force all hosts in the host file do have a full backup on last day of month
if [ $(cal | tr -s '[:blank:]' '\n' |tail -1) = $(date +%d) ]
then
  for HOST in $(cat /etc/backuppc/hosts | grep ^[A-Za-z0-9] | grep -v host | awk '{print $1}')
  do
    /usr/share/backuppc/bin/BackupPC_serverMesg backup ${HOST} ${HOST} backuppc 1
#   echo ${HOST}
  done
done


Attachment: prune_backups.sh
Description: application/shellscript

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/
<Prev in Thread] Current Thread [Next in Thread>