It's in perl, but...here you go. This is the "incremental" script, which is the one I run in cron. I usually run the full backups manually. For more info (including the "full" backup script & docs) at:
http://www.ostreet.net/software/bak3.html
Thanks for your help!
Galen
+++++++++++++++++++++++++++++++++++++++++++++
!/usr/bin/perl -w
#
# Copyright 2004 G. P. Overstreet
#
#
#
# This file is part of bak3 - Unix/Linux Backup Scripts.
#
# bak3 - Unix/Linux Backup Scripts is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# bak3 - Unix/Linux Backup Scripts is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with bak3 - Unix/Linux Backup Scripts; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
#
#
#
# Version 3 Backup Script
# Incremental Backup
# GPO 5/11/04
#
# Last Mod GPO
# 6/28/04
#
# Set paths to conf files in /etc
$etc_path = "/etc/bak3";
$conf_file = "$etc_path/bak3.conf";
open (CONF, "<$conf_file")
|| die "Can't Open file $!";
#
# Read conf file, set local variable names/values
while (<CONF>) {
@var = split;
if ($var[0] eq "local_work") {$local_work = $var[2];}
if ($var[0] eq "fname") {$fname = $var[2];}
if ($var[0] eq "numincr") {$numincr = $var[2];}
if ($var[0] eq "encrypt_opt") {$encrypt_opt = $var[2];}
if ($var[0] eq "encrypt_key_id") {$encrypt_key_id = $var[2];}
if ($var[0] eq "incr_stor_opt") {$incr_stor_opt = $var[2];}
if ($var[0] eq "remote_user") {$remote_user = $var[2];}
if ($var[0] eq "remote_host") {$remote_host = $var[2];}
if ($var[0] eq "remote_full_path") {$remote_full_path = $var[2];}
if ($var[0] eq "numskipday") {$numskipday = $var[2];}
if ($var[0] eq "util_opt") {$util_opt = $var[2];}
if ($var[0] eq "scriptpath") {$scriptpath = $var[2];}
}
close CONF;
#
# Open last for input; Read in increment number of last incr backup
$verfile = "$local_work/last-incr";
open (INFILE, "<$verfile")
|| die "Can't Open file $!";
while (<INFILE>) {
# $iver = $_;
# $skiplast = $_;
@var = split;
}
close INFILE;
#
$iver = $var[0];
$skiplast = $var[1];
#$voo = chomp $iver;
#$voo2 = chomp $skiplast;
#
# Check if you want to write remote incremental this time
$skiplast = $skiplast + 1;
if ($skiplast eq $numskipday) {
$skiplast = 0;
}
# Create filename for new full backup; increment & write new number
$old_tar_name = "$fname-full-$iver.tar";
print $old_tar_name, "\n";
for ($count = 1; $count <= $numincr; $count++) {
if ($iver eq $count) {
$foo = $iver + 1;
}
if ($iver eq $numincr) {
$foo = 1;
}
}
$new_tar_name = "$fname-incr-$foo";
open (OUTFILE, ">$verfile")
|| die "Can't Open file $!";
print OUTFILE "$foo $skiplast";
close OUTFILE;
#
# Tar the new backup file
system $vook = "cp $local_work/incr-full.dat $local_work/incr.dat";
system $vook = "tar -cvpf $new_tar_name.tar --listed-incremental $loc#
# gzip or encrypt the new backup tar file
if ($encrypt_opt eq 0) {
system $vook = "gzip -f $new_tar_name.tar";
$copy_name = "$new_tar_name.tar.gz";
}
if ($encrypt_opt eq 1) {
system $vook = "gpg -r $encrypt_key_id -e $new_tar_name.tar";
$copy_name = "$new_tar_name.tar.gpg";
system $vook = "rm $new_tar_name.tar";
}
#
# Skip remote for skipdays
if ($skiplast ne 0) {
goto NOREMOTE;
$skiplast = $skiplast + 1;
}
# copy to remote server
#
if ($incr_stor_opt gt 0) {
$vook2 = "$local_work/sftp-batch";
open (OUTFILE, ">$vook2")
|| die "Can't Open file $!";
print OUTFILE "put $copy_name $remote_full_path\nquit";
close OUTFILE;
system $vook = "sftp -b $vook2 $remote_user$remote_host";
}
NOREMOTE:
# delete local copy for incr_stor_opt = 2
if ($incr_stor_opt eq 2) {
system $vook = "rm $copy_name";
}
# Delete previous incremental backup locally if incr_stor_opt = 3
if ($incr_stor_opt eq 3) {
system $vook = "rm $fname-incr-$iver*";
}
# Run optional utility script after incremental backup is complete
if ($util_opt eq 1) {
system $vook = "$scriptpath";
}
#
al_work/incr.dat -T $etc_path/backup.files.list";