[olug] SCSI Tape drives

dutch dutch at tconl.com
Wed Mar 17 14:44:07 UTC 2004


Sorry for the long post.  See below your message for a script I used - don't 
claim to be guru script guy but it worked for me.  I think it was scsi dat on 
Intel / Linux.  I liked that I got a log + index of files backed up and the 
log identified what tape it was on.  Also that the set of logs and indexes 
was backed up every time.

Dutch

On Tuesday 16 March 2004 1:16 pm, Craig Wolf wrote:
> I am looking for a website to help me with working with a tape and the
> tape drive.  Specifically formatting a tape, appending to the end of a
> tape, reading the tape label, finding out WHAT device to reference, etc.
>  I have googled but I am not searching on the right terms apparently.
> I am writing a custom backup script and want to make sure I am doing it
> right.  Thanx to all in advance for any and all help!!  8)
>
> Craig Wolf
> Linux Web Server Support
> Desktop/Network Specialist
> 402-894-6283
>
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug



=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2003.01.16 15:58:58 =~=~=~=~=~=~=~=~=~=~=~=
clear
[root at somehost bkp]# pwd
/usr/bkp
[root at somehost bkp]# ls -alst
total 6772
   4 drwxr-xr-x    2 root     root         4096 Jan 16 16:05 .
   4 -rw-r--r--    1 root     root         1960 Jan 16 04:18 bkp-Thu-Jan-16
 204 -rw-r--r--    1 root     root       200969 Jan 16 04:18 idx-Thu-Jan-16.Z
  -- snip --
   4 -rw-r--r--    1 root     root         2462 Dec  6 04:13 bkp-Fri-Dec-06
 200 -rw-r--r--    1 root     root       199747 Dec  6 04:13 idx-Fri-Dec-06.Z
   4 drwxrwxrwx   25 root     root         4096 Dec  5 23:04 ..
   4 -rw-r--r--    1 root     root         2116 Dec  5 04:12 bkp-Thu-Dec-05
 200 -rw-r--r--    1 root     root       199379 Dec  5 04:12 idx-Thu-Dec-05.Z
   4 -rw-r--r--    1 root     root         2138 Dec  4 04:12 bkp-Wed-Dec-04
  -- snip --
   4 -r--r--r--    1 root     root          102 Oct  3 16:40 include.bkp
   4 -r-xr--r--    1 root     root         2185 Oct  3 09:26 daily.bkp
   
   
[root at somehost bkp]# cat include.bkp
/etc
/home
/root
/usr/b299
/usr/lib
/usr/local
/var


[root at somehost bkp]# cat daily.bkp
#!/bin/bash
#
# somehost Backup Script
#
# /usr/bkp/daily.bkp       - this file
# /usr/bkp/include.bkp     - what to backup
#
# rev. 10/02/02 bedwards
#
PATH=/bin:/usr/bin
HOST=`hostname`
DAY=`date +%a-%b-%d`
SETLABEL="$HOST-$DAY"
LOG="/usr/bkp/bkp-$DAY"
IDX="/usr/bkp/idx-$DAY"
MARKER="/usr/bkp/$SETLABEL"
#
TAPE=/dev/st0
NTAPE=/dev/nst0
# 
INCLUDEFILE=/usr/bkp/include.bkp
BACKUPDIRS=`cat $INCLUDEFILE`
#
echo "mark" > $MARKER 
echo "`date +%T`  Starting backup $SETLABEL"
echo "`date +%T`  LOG for $SETLABEL" > $LOG
echo "`date +%T`  IDX for $SETLABEL" > $IDX
#
echo "          Check dirs"
cd /
echo "          Check dirs" >> $LOG
for path in $BACKUPDIRS
  do
    if [ -s $path ]
      then
        du --max-depth=0 $path >> $LOG
      else
        echo "MISSING $path" >> $LOG
    fi
  done
#
echo "          Rewind"
echo "          Rewind" >> $LOG
#
echo "          Turn on compression"
echo "          Turn on compression" >> $LOG
mt -f $TAPE datcompression 1 >> $LOG
#
echo "`date +%T`  Read tape label (if exists)"
echo "`date +%T`  Read tape label (if exists)" >> $LOG
mt -f $NTAPE fsf 1 >>$LOG
tar t -f $NTAPE "$HOST*" >> $LOG 2>>$LOG
mt -f /dev/st0 rewind
#
echo "          Erase tape"
echo "          Erase tape" >> $LOG
mt -f $TAPE erase >> $LOG
#
echo "`date +%T`  Starting backup"
echo "`date +%T`  Starting backup" >> $LOG
tar cv --totals --label $SETLABEL -f $TAPE $BACKUPDIRS >> /dev/null 2>>$LOG
echo "`date +%T`  Finished backup"
echo "`date +%T`  Finished backup" >> $LOG
#
echo "          Sleeping 10"
sleep 10
#
echo "`date +%T`  Verifying backup"
echo "`date +%T`  Verifying backup" >> $LOG
tar dv -f $TAPE >> $IDX 2>>$LOG
grep ": " < $IDX
grep ": " < $IDX >>$LOG
echo "`date +%T`  Finished verify"
echo "`date +%T`  Finished verify" >>$LOG
#
echo "`date +%T`  Save bkp directory to tape"
echo "`date +%T`  Save bkp directory to tape" >> $LOG
mt -f $NTAPE fsf 1
tar cv --totals --label $SETLABEL -f $NTAPE /usr/bkp >> /dev/null 2>>$LOG
mt -f $TAPE rewind
#
echo "END LOG $SETLABEL" >> $LOG
echo "END IDX $SETLABEL" >> $IDX
echo "          Compressing $IDX"
compress -f $IDX
rm $MARKER
echo " "
echo "Done, detail in $LOG and $IDX"
echo " "
#
# end of file


[root at somehost bkp]# cat bkp-Thu-Jan-16
02:55:01  LOG for somehost-Thu-Jan-16
          Check dirs
3480/etc
1494716/home
7272/root
MISSING /usr/b299
180448/usr/lib
128/usr/local
173532/var
          Rewind
          Turn on compression
Compression on.
02:55:14  Read tape label (if exists)
somehost-Thu-Dec-19
          Erase tape
02:57:24  Starting backup
tar: Removing leading `/' from member names
tar: /usr/b299: Cannot stat: No such file or directory
tar: /var/log/secure: file changed as we read it
Total bytes written: 3078062080 (2.9GB, 1.1MB/s)
tar: Error exit delayed from previous errors
03:40:54  Finished backup
03:41:04  Verifying backup
var/lib/logrotate.status: Mod time differs
var/log/secure: Mod time differs
var/log/secure: Size differs
var/log/wtmp: Mod time differs
var/log/wtmp: Size differs
var/log/sa/sa16: Mod time differs
var/log/sa/sa16: Size differs
var/log/cron: Mod time differs
var/log/cron: Size differs
var/cache/man/whatis: Mod time differs
var/run/utmp: Mod time differs
var/run/utmp: Contents differ
var/spool/anacron/cron.daily: Mod time differs
var/spool/anacron/cron.daily: Contents differ
04:16:32  Finished verify
04:16:32  Save bkp directory to tape
tar: Removing leading `/' from member names
Total bytes written: 21667840 (21MB, 572kB/s)
END LOG somehost-Thu-Jan-16
[root at somehost bkp]# 



More information about the OLUG mailing list