Re: Incremental Backups

Rob Cotrone <[email protected]> Mon, 07 Jun 2004 12:38:42 -0400
Newsgroups gmane.comp.sysutils.backup.hdup.general
Message-ID <[email protected]>
 > I hate scheduling monthly, weekly and daily backups in
 > the cron script because they can potentially overwrite each other.
 > Any pitfalls doing it this way?


Here is a very simple script that can be run via cron to insure the 
backups (monthly,weekly,daily) do not step on one another.
Hope this helps.


#!/usr/bin/perl

$hdup = "/usr/sbin/hdup";
# $sshhost = "\@backup\@backupserver";
$sshhost = "";

chop($daynum = `/bin/date +%d`);
chop($hostname = `/bin/hostname -s`);

if ( $daynum == 1 ) {
   print `$hdup monthly $hostname $sshhost`;
   print `$hdup weekly $hostname $sshhost`;
   print `$hdup daily $hostname $sshhost`;
}
elsif ( $daynum % 7 == 0 ) {
   print `$hdup weekly $hostname $sshhost`;
   print `$hdup daily $hostname $sshhost`;
}
else {
   print `$hdup daily $hostname $sshhost`;
}


 > When the monthly files get deleted, and hdup has to recreate them,
 > what will happen to the old daily files?

A. the daily files will sit around until they get purged.
B. I'm not sure how much information can be restored with the daily's
    and/or if you can use hdup to do the restore because the monthly
    may not exist. At some point when the monthly was purged we had
    to restore a file from the daily manually.

    When I went to do a mass restore,
    It wanted the monthly, weekly and then the daily.

Franky, I have to experiment more with this.
The new version has a --dry-run mode so it can be tested.


 > Maybe full backups are the only way to go, here.

I may just change my scheme to keep the monthly files for 64 days and 
purge the rest as per schedule. Currently on the first of the month I 
archive the current backup directory to another HD and take it off line.



Trevor wrote:

> Does anybody know if I can simply use the following script to do incremental
> backups on a monthly basis?  I have it set to do a daily backup every day.
> Because, "force" is enabled, if it cannot find a monthly, or a weekly
> backup, it does one, automatically.  The purge script will delete any files
> older than 32 days.  I hate scheduling monthly, weekly and daily backups in
> the cron script because they can potentially overwrite each other.  Any
> pitfalls doing it this way?  It's been working for four days, so far.
> 
> I suppose I will end up with 1 monthly, 1 weekly and 30 daily directories.
> That's ok, as long as I can do a restore.  When the monthly files get
> deleted, and hdup has to recreate them, what will happen to the old daily
> files?
> 
> Maybe full backups are the only way to go, here.
> 
> ---
> 
> Basically, this is my network backup cron job:
> 
> # Network Backup enabled. (* 9:30)
> 0 9 * * *  	root /usr/bin/smbumount /mnt/winshare > /dev/null 2>&1
> 2 9 * * *  	root /usr/bin/smbmount //192.168.1.65/backup /mnt/winshare -o
> username=xxxx,password=xxxx > /dev/null 2>&1
> 5 9 * * *   root /bin/nice -10 /usr/bin/purgedir.pl /mnt/winshare 32 >
> /dev/null 2>&1
> 30 9 * * *  root /bin/nice -15 /usr/sbin/hdup daily server | mail -s "Server
> Network Backup" postmaster
> 
> ---
> 
> The purge.pl script can be found here:
> http://pflanze.mine.nu/~chris/scripts/utilities/purgeolditems
> 
> ---
> 
> Output for /etc/hdup/hdup.conf:
> 
> [global]
> archive dir = /mnt/winshare
> date spec = iso
> tar = /bin/tar
> always backup = on
> skip = on
> force = on
> free = 5000m
> no history = no
> log = on
> overwrite = on
> proto = /usr/bin/ssh
> proto option =  -q -oProtocol=2
> user = admin
> compression = gzip
> compression level = 4
> 
> # ----------------------------------------
> # backup configurations
> # ----------------------------------------
> 
> [server]
> dir = /home/myfiles
> chunk size = 2000m
> allow remote = no
> 
> 
> --- Thanks, Trevor.
>