Listing 1: Backup script
#!/usr/bin/perl
# *************************
# General Use Backup Script
# *************************
#
# Mark L. Nassal
# 1997
#
# *************************
system "clear";
# Create Menu
print "Interactive Backup Script\n";
print "===================================\n";
print " \n";
print "1. Monthly Backup\n";
print "2. Weekly Backup\n";
print "3. Daily Backup\n";
print "4. Exit\n";
print " \n";
print "===================================\n";
print " \n";
print "Enter choice (1,2,3,4): ";
$answere = <>;
chomp $answere;
if ($answere eq "1" ) {
# Open log file
$blog = "/var/log/backup.log";
open (BACKU,">>$blog") || die "Cant open the log file $!";
print BACKU "================================================\n";
# *****************************************************
# Edit tape devices, tape length, and path to meet
# your needs. I have repeated the device list in each
# if statement so you can use larger devices for full
# dumps and smaller devices for dailys.
# *****************************************************
system "mt -f /dev/st0 rewind";
system "/sbin/dump 0unfB /dev/nst0 2048000 /usr";
system "/sbin/dump 0unfB /dev/nst0 2048000 /home";
system "/sbin/dump 0unfB /dev/nst0 2048000 /export";
system "/sbin/dump 0unfB /dev/nst0 2048000 /opt";
system "mt -f /dev/st0 offline";
# ****************************************************
# ****************************************************
$dumpdate = "/etc/dumpdates";
open (DFILE,"<$dumpdate") || die "Cant open /etc/dumpdates";
while(<DFILE>){
print BACKU
}
exit()
}
elsif ($answere eq "2" ) {
# Open log file
$blog = "/var/log/backup.log";
open (BACKU,">>$blog") || die "Cant open the log file $!";
print BACKU "================================================\n";
# *****************************************************
# Edit tape devices, tape length, and path to meet
# your needs. I have repeated the device list in each
# if statement so you can use larger devices for full
# dumps and smaller devices for dailys.
# *****************************************************
system "mt -f /dev/st0 rewind";
system "/sbin/dump 5unfB /dev/nst0 2048000 /usr";
system "/sbin/dump 5unfB /dev/nst0 2048000 /home";
system "/sbin/dump 5unfB /dev/nst0 2048000 /export";
system "/sbin/dump 5unfB /dev/nst0 2048000 /opt";
system "mt -f /dev/st0 offline";
# ****************************************************
# ****************************************************
$dumpdate = "/etc/dumpdates";
open (DFILE,"<$dumpdate") || die "Cant open /etc/dumpdates";
while(<DFILE>){
print BACKU
}
exit()
}
elsif ($answere eq "3" ) {
# Open log file
$blog = "/var/log/backup.log";
open (BACKU,">>$blog") || die "Cant open the log file $!";
print BACKU "================================================\n";
# *****************************************************
# Edit tape devices, tape length, and path to meet
# your needs. I have repeated the device list in each
# if statement so you can use larger devices for full
# dumps and smaller devices for dailys.
# *****************************************************
system "mt -f /dev/st0 rewind";
system "/sbin/dump 5unfB /dev/nst0 2048000 /usr";
system "/sbin/dump 5unfB /dev/nst0 2048000 /home";
system "/sbin/dump 5unfB /dev/nst0 2048000 /export";
system "/sbin/dump 5unfB /dev/nst0 2048000 /opt";
system "mt -f /dev/st0 offline";
# ****************************************************
# ****************************************************
$dumpdate = "/etc/dumpdates";
open (DFILE,"<$dumpdate") || die "Cant open /etc/dumpdates";
while(<DFILE>){
print BACKU
}
exit()
}
elsif ($answere eq "4" ) {
&quit_app();
}
else {
print "You must enter a number between 1 and 4\n";
exit();
}
sub quit_app {
print "bye\n";
exit();
}
# *************
# End of Script
# *************
|