Backup software
Glenn Burkhardt
glenn at vtecus.com
Mon Dec 3 13:42:51 EST 2001
> I am looking for dependable backup software that handles both full and
> incremental backups. I need to beable to do occassional network backups of
> single machines for maintenance purposes. The backup device is a Seagate 4G
> IDE Tape drive.
Attached are the scripts I have 'cron' run each night. They do full and
incremental backups of Linux, Solaris, SunOS, Win9x and WinNT machines.
All that's required is 'rsh' access to the Unix boxes, Samba, and 'bash'.
I've been using scripts for network backups for years - we have a small shop
(~20 machines), and it's been more than adequate.
-------------- next part --------------
#!/bin/bash
#
append() # append item to backup list table
{
n=${#blist[*]}
blist[$n]=$1
}
# Backup table
#
# host platform filesystem levels (Full/Incremental MTWTF)
append 'aoi SunOS /dev/rsd0a F I I I I'
append 'aoi SunOS /dev/rsd0g F I I I I'
append 'aoi SunOS /dev/rsd0h F I I I I'
append 'aoi SunOS /dev/rsd0c F I I I I'
append 'aoi SunOS /dev/rsd0d F I I I I'
append 'aoi SunOS /dev/rsd1c I F I I I'
append 'aoi SunOS /dev/rsd2c I F I I I'
append 'aoi SunOS /dev/rsd3c I F I I I'
#####################
append 'brontes SunOS /dev/rsd0a I F I I I'
append 'brontes SunOS /dev/rsd0g I F I I I'
append 'brontes SunOS /dev/rsd0h I F I I I'
#####################
append 'artemis SunOS /dev/rsd0a I F I I I'
append 'artemis SunOS /dev/rsd0g I F I I I'
append 'artemis SunOS /dev/rsd0h I I F I I'
append 'artemis SunOS /dev/rsd3a I I F I I'
append 'artemis SunOS /dev/rsd3b I I F I I'
append 'artemis SunOS /dev/rsd3d I I F I I'
#####################
append 'loki LinuxTar /mnt/windows/gbb I I I F I'
append 'loki Linux /dev/sda2 I I I F I'
#####################
append 'pendragon Linux /dev/hda1 I I I F I'
#####################
append 'raijin Linux /dev/hda1 I I I F I'
#####################
append 'ceres Solaris /dev/rdsk/c0t0d0s0 I I I F I'
append 'ceres Solaris /dev/rdsk/c0t0d0s7 I I I F I'
#####################
append 'priam LinuxTar /etc F F F F F'
append 'priam LinuxTar /var/named F F F F F'
append 'priam LinuxTar /usr/local I I I I F'
append 'priam LinuxTar /root I I I I F'
#####################
append 'hydra SunOS /dev/rsd0a I I I F I'
append 'hydra SunOS /dev/rsd0g I I I F I'
append 'hydra SunOS /dev/rsd0h I I I F I'
append 'hydra SunOS /dev/rsd6c I I I I F'
append 'hydra SunOS /dev/rsd2c I I I I F'
#####################
#append 'tohoten Linux /dev/hda1 I I I I F'
#####################
append 'lugia Linux /dev/hda5 I I I I F'
#####################
# Using 'dd' to write the tape avoids requiring .rhosts on artemis (owner
# of the tape drive) giving access to root from the other systems. If
# the command were of the form 'rsh <remothost> dump f artemis:/dev/rst0',
# artemis would need to give root rsh privileges to <remotehost>. Not doing
# this avoids giving system wide superuser privileges to people with Unix
# machines on their desks, while allowing those same people to have
# superuser privileges for the machines on their desks.
#
TAPEDEV=/dev/nst0
WRT_TAPE="dd of=$TAPEDEV obs=126b"
error_exit()
{
echo "The nightly backup failed" | mail -s "backup failed" backuplist
mt -f $TAPEDEV rewoffl
exit
}
dump_host() # args: host platform filesystem levels day_of_week
{
echo '####################'
date
# first test if we can access remote host
rsh -n $1 echo
if [ $? != 0 ] ; then
echo "rsh to $1 failed" | mail -s "backup failed" backuplist
return
fi
day=$(($9 + 2))
level=${!day} # evaluate $day'th positional argument
if [ $level = F ] ; then
dl=0
echo File $fileno: Full backup of $3 on $1
else
dl=5
echo File $fileno: Incremental backup of $3 on $1
fi
case $2 in
SunOS) rsh -n $1 /etc/dump ${dl}uf - $3 | $WRT_TAPE ;;
Solaris) rsh -n $1 /usr/sbin/ufsdump ${dl}uf - $3 | $WRT_TAPE ;;
Linux) rsh -n $1 /sbin/dump ${dl}uf - $3 | $WRT_TAPE ;;
LinuxTar) if [ $level = F ] ; then
rsh -n $1 tar zcf - $3 | $WRT_TAPE
else
rsh -n $1 tar zcf - -N \"7 days ago\" $3 | $WRT_TAPE
fi ;;
esac
if [ $? != 0 ] ; then error_exit ; fi
fileno=$(($fileno + 1))
}
date
mt -f $TAPEDEV rewind
if [ $? != 0 ] ; then error_exit; fi
#
#set -v
cd /root/backup
# Put a copy of the backup scripts on the tape as File 0
tar cvf $TAPEDEV backup pc.backup
if [ $? != 0 ] ; then error_exit; fi
# Determine backup level for today. Get the day of the week, and
# add in the offset to the backup level arguments. The crontab entries
# run backups starting at midnight, Monday night - Friday night, so
# the day of week numbers will be 2-6. The level arguments start at $4.
if [ $# -eq 1 ] ; then
case $1 in
monday) day_of_week=2 ;;
tuesday) day_of_week=3 ;;
wednesday) day_of_week=4 ;;
thursday) day_of_week=5 ;;
friday) day_of_week=6 ;;
*) echo use day of week in lowercase
exit ;;
esac
else
day_of_week=$((`date +%w`))
if [ $day_of_week -lt 2 ] ; then day_of_week=2 ; fi
if [ $day_of_week -gt 6 ] ; then day_of_week=6 ; fi
fi
# Main loop. Execute the backup for each host entry.
fileno=1
i=0
while [ $i -lt ${#blist[*]} ] ; do
dump_host ${blist[$i]} $day_of_week
i=$(($i + 1))
done
# Roll over the transaction log
rsh -n artemis /backup/minxkill
date
echo File $fileno - 'M$-win units'
/root/backup/pc.backup $fileno
mt -f $TAPEDEV rewoffl
-------------- next part --------------
#! /bin/bash
if [ $# = 0 ] ; then
fileno=0
else
fileno=$1
fi
SMBC=/usr/local/samba/bin/smbclient
cd /root/backup
TAPE=/dev/nst0
sendFailed()
{
echo email to $2 re: $1 not available
echo $'Backups were not done this evening because your machine is not available on\nthe network. Please be sure to leave your machine on each night so backups\ncan be done. Thank you!' | mail -c backuplist -s $1 $2
}
EXCLUDE='windows winnt dos xnfs orcadwin MAXPLUS2 emacs OmniX OmniNFSXe \
MSOffice Office wpwin60 Acrobat3 engr wpc20 DMI ATI PAGEMGR KPCMS OPLIMIT \
wpwin60 dell mouse vibra16 teac winmcad win32app acroread acrobat3 \
bsdl pkware ACADR13 DTEXT23 MCVHDL RECYCLED lotus Corel Eudora/eudora.log \
ACER MAX2WORK ticd abel3 clipart HPFONTS ORCADWIN ICM98 OrCad2 gs \
ALLIED99 CKWIN7 gstools PSFONTS synplicity WINPROJ Ck99R2 COMPAQ max2key'
# Hosts with <ADMINPASSWORD> remote access account
#
#
blAppend()
{
n=${#hlist[*]} # appednd to host list
hlist[$n]=$1
n=${#slist[*]} # append to share list
slist[$n]=$2
n=${#olist[*]} # append to owner email name list
olist[$n]=$3
}
# Build list of
# host share user-to-notify
blAppend drachma C glenn
blAppend kopek C johnf
blAppend masada C mike
blAppend vishnu C maureen
blAppend aries C laura
blAppend pellinore C ellen
blAppend sappho C charlie
blAppend diana C pbm
blAppend mordred C jamie
blAppend gawaine C neal
blAppend tristan C craig
blAppend tristan D chris
blAppend fujin C jim
i=0
while [ $i -lt ${#hlist[*]} ] ; do
echo
date
echo ping ${hlist[$i]}
ping -c 1 ${hlist[$i]}
if [ $? != 0 ] ; then
sendFailed ${hlist[$i]} ${olist[$i]}
else
echo File ${fileno}: ${hlist[$i]}
$SMBC \\\\${hlist[$i]}\\${slist[$i]} "<ADMINPASSWORD>" -TcbX 126 $TAPE \
"Program Files" "To Clean" $EXCLUDE \
&> ${hlist[$i]}-${slist[$i]}.log
if [ $? != 0 ] ; then
sendFailed ${hlist[$i]} ${olist[$i]}
fi
fileno=$(($fileno + 1))
fi
i=$(($i + 1))
done
echo "PC backups complete"
date
More information about the Discuss
mailing list