Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
I run a backup of all our machines (Linux, SunOS, Solaris, Win98, WinNT) each night on a DDS-3 drive. I have two scripts (attached), run by 'cron' each night. It's been working fine for years. You don't mention how many machines you're backing up, though. P.S. The scripts require Bash... -------------- 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/rsd1c F I 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/nt/gbb I I I F I' append 'loki Linux /dev/sda2 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 '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 'pendragon Linux /dev/hda1 I I I F I' ##################### append 'raijin Linux /dev/sda2 I I I F I' append 'raijin Linux /dev/sdb1 I I I F I' ##################### append 'muse Linux /home 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' # 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 { 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 # 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. day_of_week=$((`date +%w` + 2)) if [ $day_of_week -lt 4 ] ; then day_of_week=4 ; fi if [ $day_of_week -gt 8 ] ; then day_of_week=8 ; fi level=${!day_of_week} 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 # Main loop. Execute the backup for each host entry. fileno=1 i=0 while [ $i -lt ${#blist[*]} ] ; do dump_host ${blist[$i]} 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 FAILED_MSG="\ Backups were not done this evening because your machine is not available on\n\ the network. Please be sure to leave your machine on each night so backups\n\ can be done. Thank you!" 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' # Hosts with full access to shares with <PASSWORD> # # 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 sandra blAppend kopek C johnf blAppend masada C mike blAppend vishnu C maureen blAppend aries C laura blAppend fujin C jim blAppend fujin D jim blAppend pellinore C ellen blAppend sappho C dolores blAppend diana C pbm blAppend osimo C yvan i=0 while [ $i -lt ${#hlist[*]} ] ; do echo date echo ping ${hlist[$i]} ping -c 1 ${hlist[$i]} if [ $? != 0 ] ; then echo email to ${olist[$i]} for ${hlist[$i]} not available echo $FAILED_MSG | mail -s "Backup for ${hlist[$i]} failed" ${olist[$i]} echo $FAILED_MSG | mail -s "Backup for ${hlist[$i]} (${olist[$i]}) failed" backuplist else echo File ${fileno}: ${hlist[$i]} $SMBC \\\\${hlist[$i]}\\${slist[$i]} "PASSWORD" -TcbX 126 $TAPE \ "Program Files" $EXCLUDE &> ${hlist[$i]}-${slist[$i]}.log fileno=$(($fileno + 1)) fi i=$(($i + 1)) done echo "PC backups complete" date
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |