SUMMARY: Ufsdump Backup Check Script

From: Ryan Lewis (
Date: Mon Oct 06 1997 - 00:42:21 CDT

Thanks to those who replied, my question was .......

> Dear Gurus,
> I am planning to write a script that will check the integrity of our backups, performed using ufsdump. At the moment this is done manually - tedious at the best of times!
> > Basically, the script would access each tape, ensuring that for each filesystem dump, files can be accessed, directories navigated, and maybe a sample file restored - or something to that effect, with the results written to a log file that would be mailed to the operator.
> > Are there similar scripts (or something more involved) in existance?

Here's a summary of the replies:
Stephen Harris suggested the following ........
put a file on each mountpoint called
`hostname`.`basename diskname`

eg if the host was "fred" and the disk "/dev/dsk/c0t0d0s0" then the file is called "fred.c0t0d0s0"

This ensures the file is different for each partition. Then while doing a backup I keep track of the files in a string, and then afterwards just loop round testing each image one by one to see if the file can be seen
(t option to restore). Although this doesn't guarantee that the image is successful, at least it shows the directory tree can be read OK.

Khoo Boon Hing sent the following script that was picked up from sun-managers a while back ....

#!/bin/csh set verbose set day = `date +%y%m%d`
#echo "start by making a tarfile from the sparcbook"
#mount rodenta:/export/home /mnt
#tar cvf /export/home/bert/tarfile_from_rodenta /mnt/users/demo
#compress /export/home/bert/tarfile_from_rodenta
#umount /mnt
#echo "now for a tarfile from samee"
#mount samee:/c /mnt
#tar cvf /disk/tarfile_from_samee /mnt
#umount /mnt
#compress /disk/tarfile_from_samee echo "now for the real backups" mt -f /dev/rmt/0n rew ufsdump 0uf /dev/rmt/0bn / ufsdump 0uf /dev/rmt/0bn /usr ufsdump 0uf /dev/rmt/0bn /var ufsdump 0uf /dev/rmt/0bn /export/home ufsdump 0uf /dev/rmt/0bn /opt
#ufsdump 0uf /dev/rmt/0bn /disk echo "now test the backups." mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 1 >
/export/home/bert/dumpfile1.${day} mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 2 >
/export/home/bert/dumpfile2.${day} mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 3 >
/export/home/bert/dumpfile3.${day} mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 4 >
/export/home/bert/dumpfile4.${day} mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 5 >
#mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 6 >
/export/home/bert/dumpfile6.${day} mt -f /dev/rmt/0n rew
D. Ellen March wrote ....
We have a tape library that currently holds 4 tapes.
In the morning I load tape number one in the drive.

Then I run the following:

  echo "verify of backups has begun..." date
/opt/Backups/ sleep 15 mt -f /dev/rmt/0m rewoffl sleep 30 mt -f /dev/rmt/0mn asf 1
/opt/Backups/ sleep 15 mt -f /dev/rmt/0m rewoffl sleep 30 mt -f /dev/rmt/0mn asf 1
/opt/Backups/ sleep 15 mt -f /dev/rmt/0m rewoffl sleep 30 mt -f /dev/rmt/0mn asf 1
/opt/Backups/ sleep 15 mt -f /dev/rmt/0m rewoffl echo "verify of backups has finished..." date

The script being called is:

  dump=1 status=0
  while [ $status = 0 ] do
   ufsrestore if $TAPE <<EOF > $LOGTEMP 2>/dev/null what quit
   if [ $status = 0 ] ; then
      echo Dump file \#$dump >>$LOGFILE
      cat $LOGTEMP >> $LOGFILE
      echo "" >> $LOGFILE
      dump=`expr $dump + 1`
   fi done

Then I look at the /tmp/logfile.verify file and compare it to my backup log. If everything matches, we are in business!

Jason Keltz wote ....
As part of my (freely available) backup system that uses ufsdump
(, I do my own integrity check. Before the backup is done, I dump a file called ".LastBackup" in the root of the filesystem being backed up containing the date and time (output of date command). I keep track of these dates and times in another file. When the backup is complete, I rewind and restore each of these date stamps, all the while making sure that they compare. This proves that a file can be restored, and the contents are verified. What I like is that at any point, I can look at a filesystem .LastBackup file, and determine the last time it was backed up. If the date stamps do not match, I also move the file to .LastBackup.bad so that I have an indication of when the last "bad" backup was.

Thanks also to Rich Kulawiec for his advice.


Ryan Lewis
ZESPRI International Ltd

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:04 CDT