#!/bin/csh # # Copyright 2004 Michael L. Love (GPL) # # Load two discs with one in each burner, then source this file like so... # # source ~/burnIt go # # If all goes well, the resulting # backup discs will be test-read and each file will be check-summed, so that a # valid backup is assured. Checksums will also be recorded to the backup discs # for restoration purposes. # # If everything goes as planned, and the check-sums match, then you will have # two identical backup copies to take with you. # # Change log # # 1.6 added better mktemp portability and checksum_dir for checksumming # specific files ######## # here is the code ######## # parse $1 first, must be one of: # go checksums mount eject diffs remount load, # else echo usage setenv chkArgs false foreach i (go checksums mount eject diffs remount load checksum_dir) if ( $i == $1 ) then setenv chkArgs true endif end if ( $chkArgs == "false" ) then echo 'Usage: source burnit-1.2a go ' exit endif goto $1 go: echo Backing up in current directory... setenv theFiles `echo $* | sed s/'^'{$0}// | sed s/'^'{$1}//` echo $theFiles # some problem here, need strlen ;-} #if ( $theFiles == '' ) then #echo 'Usage: source burnit-1.2a go ' #exit #endif setenv thetmpdir `mktemp -d` setenv serialNum `echo $thetmpdir|sed s/'\/tmp\/tmp\.'//g` mkdir -p burnit-$serialNum chmod 777 burnit-$serialNum echo 'serial: '$serialNum setenv theDir `pwd` setenv theName `echo $theDir|sed s/'\/'/'_'/g`'-'$serialNum'.iso' # # Need sanity checks here, priority high # dvdrecord dev=/dev/rcd0c speed=4 -dao -v -load& dvdrecord dev=/dev/rcd1c speed=4 -dao -v -load& checksums: mkdir -p ~/md5sums rm -rf ~/md5sums/sum-0$theName ~/md5sums/sum-1$theName ~/md5sums/sum-F$theName ./sum-F$theName echo 'Temporarily moving the files to compatibility directory, 'burnit-$serialNum'...' echo Getting file names... # # Need sanity checks here, priority medium # mktemp reliable, but directory writable? # mv $theFiles burnit-$serialNum cd burnit-$serialNum setenv theFiles `tar -cf - $theFiles | tar -tf -` echo File names done. echo Checksumming disk ... foreach i ( $theFiles ) echo $i md5 $i >>~/md5sums/sum-F$theName end cp ~/md5sums/sum-F$theName ./sum-F$theName echo Checksumming disk done. # # Need sanity checks here, priority high # mkisofs -l -R . >$theDir/../$theName wait cd $theDir mv burnit-$serialNum/* . rmdir burnit-$serialNum # # Need sanity checks here, priority low # dvdrecord dev=/dev/rcd0c speed=4 -dao -v $theDir/../$theName dvdrecord dev=/dev/rcd1c speed=4 -dao -v $theDir/../$theName mount: echo Attemping to mount backup discs... # # reload to clear drive buffers # dvdrecord dev=/dev/rcd0c speed=4 -dao -v -eject& dvdrecord dev=/dev/rcd1c speed=4 -dao -v -eject& wait dvdrecord dev=/dev/rcd0c speed=4 -dao -v -load& dvdrecord dev=/dev/rcd1c speed=4 -dao -v -load& wait # # Need sanity checks here, priority high # mount -t cd9660 /dev/cd0a /mnt/cdrom0 mount -t cd9660 /dev/cd1a /mnt/cdrom1 echo To see if the discs are mounted type df. echo Now checksumming cdrom0 ... cd /mnt/cdrom0 foreach i ( $theFiles ) echo $i md5 $i >>~/md5sums/sum-0$theName end echo Now checksumming cdrom1 ... cd /mnt/cdrom1 foreach i ( $theFiles ) echo $i md5 $i >>~/md5sums/sum-1$theName end echo Checksumming done ... cd $theDir eject: echo Unmounting and ejecting... umount /mnt/cdrom0 /mnt/cdrom1 eject cd0c& eject cd1c& wait diffs: echo There should be nothing below this line, but if there is, then check the files. Done! diff ~/md5sums/sum-F$theName ~/md5sums/sum-1$theName |grep -v sum-.$theName diff ~/md5sums/sum-F$theName ~/md5sums/sum-0$theName |grep -v sum-.$theName diff ~/md5sums/sum-0$theName ~/md5sums/sum-1$theName |grep -v sum-.$theName exit # for the paranoid, it is also possible to checksum the discs with the following # code. # # foreach i ( /dev/rcd0a /dev/rcd1a ) # cat $i |md5 # end remount: dvdrecord dev=/dev/rcd0c speed=4 -dao -v -load& dvdrecord dev=/dev/rcd1c speed=4 -dao -v -load& wait # # Need sanity checks here, priority low # mount -t cd9660 /dev/cd0a /mnt/cdrom0 mount -t cd9660 /dev/cd1a /mnt/cdrom1 echo To see if the discs are mounted type df. exit load: dvdrecord dev=/dev/rcd0c speed=4 -dao -v -load& dvdrecord dev=/dev/rcd1c speed=4 -dao -v -load& wait exit checksum_dir: setenv theFiles `echo $* | sed s/'^'{$0}// | sed s/'^'{$1}//` echo $theFiles setenv thetmpdir `mktemp -d` setenv serialNum `echo $thetmpdir|sed s/'\/tmp\/tmp\.'//g` echo 'serial: '$serialNum mkdir -p ~/md5sums rm -rf ~/md5sums/sum-F$serialNum echo Getting file names... echo Checksumming disk ... foreach i ( `tar -cvf /dev/null $theFiles` ) echo $i md5 $i >>~/md5sums/sum-F$serialNum end echo Checksumming disk done.