[GLLUG] simple backup script I use

Felicia Berryman felicia@lon-capa.org
Wed, 17 Jul 2002 10:58:51 -0400

I don't know if this will help anyone, but this is the backup script
I've been using:

# Script to back up all --> /home, /home2, /usr, /var, and /
set TODAY=`date +%y%m%d`
set LOGFILE=/usr/local/logs/backup.log.$TODAY
echo "backup for MY_MACHINE" >>& $LOGFILE
echo " " >> $LOGFILE
foreach  tmp (/home /home2 /usr /var /) 
        dump -0 -f /dev/nst0 -B 32226562 $tmp >>& $LOGFILE
# 32226562 is 30G/1024 (30G is uncompressed size of tape)
sleep 30 
mt -f /dev/nst0 rewoffl >>& $LOGFILE
/bin/mail felicia@lite.msu.edu < $LOGFILE

If I remember correctly, I had to use nst0 and NOT st0 for the tape
drive.  It was a while ago, but I think st0 couldn't handle more than
one dump (or something like that).

Name the script something like backup.tcsh and then run backup.tcsh with
root's crontab.  

# crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.6233 installed on Sat Dec 23 09:33:51 2000)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp
0 3 * * 1,2,3,4,5 /root/backup.tcsh

These are my handy notes for retrieving backups that I've unfortunately
had to use at times:

mt -f /dev/nst0 rewind
mt -f /dev/nst0 fsf 1    (use this to move to other "directory") 
        fsf 0:  /home
        fsf 1: /home2
        fsf 2: /usr
        fsf 3: /var
        fsf 4: /
restore -i -f /dev/nst0  --->  write to the directory you are in (or use
        restore > add dir_name
        restore > add file_name  (can add more than one thing)
        restore > extract
        Specify next volume #: 1 
        set owner/mode for '.'? [yn] y
        restore > quit

I hope to edit the script when I have time to show how much tape I have
left (maybe with mt?) or use the file sizes from the log file to at
least show how much is used before compression.

Felicia Berryman
LON-CAPA Coordinator
Michigan State University
  Email:  felicia@lon-capa.org
  Phone:  (517)432-9866