#!/opt/perl/bin/perl -w
# Backup pilot with date stamp on directory
$vernum = "1.0 - 04 MAR 99" ;           # Code version and modify date
#
# This code copyright 1999 by
# D. W. Eaton, Artronic Development, Phoenix, AZ -- dwe@arde.com
#
# This software is made freely available under the provisions of the Perl
# "Artistic" license:  http://language.perl.com/misc/Artistic.html
#
# This code is not supported and is not warranteed to perform any particular
# function. Contact dwe@arde.com for aditional information.
# If you find bugs or make enhancements, it would be appreciated if you
# sent them on to the author at dwe@arde.com.
#
#
use vars '$sec','$min','$hour','$mday','$mon','$year','$wday','$yday','$isdst';

#
# Get today's date
$today = time;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
 localtime($today);
$mon++;
$year += 1900;

if ($mon < 10)
{
 $mon = "0" . $mon;
}

$daytag = $year . $mon . $mday;
$bkupdir = "pilot-backup/full-" . $daytag;

if (-e $bkupdir)
{
 print STDERR "ERROR: '$bkupdir' already exists. Delete it to overwrite.\n";
}
else
{
 # Go ahead:
 $doneok = system ("pilot-xfer /dev/pilot -b $bkupdir");
 if ($doneok)
 {
  print "Not OK\n";
  print "$doneok - $!\n";
 }
 else
 {
  print "Backup to '$bkupdir' OK\n";
 }
}
