Ultra2 Backup Boot Disk Script

August 18th, 2009

This script is a bit crude but it does work if the system is not real busy.  Another solution is to use SVM and mirror the disks.  The problem there however is; if a disk is lost and the system goes down it will not come up since SVM needs a quarum (over half) with the metadb’s. 

 I use the below scipt plus dump a flar to another system.  I really need to convert this disk to cpio.

# This script backs up the primary to secondary hard disk on an ultra class machine.
# c0t0d0 is the primary disk
# c0t1d0 the secondary disk
# s0 is / s3 is /var s7 is /work.

# This partitions the secondary disk to match the primary disk of same geometry.
prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s – /dev/rdsk/c0t1d0s2

# Make backup directory mount points if not present.
if (! -d /root1) mkdir /root1
if (! -d /var1) mkdir /var1
if (! -d /work1) mkdir /work1

# Unmount the partitions of secondary disk if they are mounted.
if ( -e /root1/lost+found) umount /dev/dsk/c0t1d0s0
if ( -e /var1/lost+found) umount /dev/dsk/c0t1d0s3
if ( -e /work1/lost+found) umount /dev/dsk/c0t1d0s7

# Newfs partitions of the secondary disk.
newfs -v /dev/rdsk/c0t1d0s0 < /dev/null
newfs -v /dev/rdsk/c0t1d0s3 < /dev/null
newfs -v /dev/rdsk/c0t1d0s7 < /dev/null

# Mount secondary disks
mount /dev/dsk/c0t1d0s0 /root1
mount /dev/dsk/c0t1d0s3 /var1
mount /dev/dsk/c0t1d0s7 /work1

# Dump from primary to seconday
ufsdump 0sf 5000000 – / | (cd /root1; ufsrestore rf – )
ufsdump 0sf 5000000 – /var | (cd /var1; ufsrestore rf – )
ufsdump 0sf 5000000 – /work | (cd /work1; ufsrestore rf – )

# Install boot block on secondary disk
installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0

# Update motd
echo `uname -rsvi`” Primary disk” > /etc/motd
echo “Backup copy on “`date` >> /etc/motd
echo `uname -rsvi`” Secondary disk” > /root1/etc/motd
echo “Backup copy on “`date` >> /root1/etc/motd

# Change /root1/etc/vfstab to enable boot disk1
sed ‘s/c0t0/c0t1/g’ /etc/vfstab > /root1/etc/vfstab

# Unmount backup disk.
umount /dev/dsk/c0t1d0s0
umount /dev/dsk/c0t1d0s3
umount /dev/dsk/c0t1d0s7

Trackback URI | Comments RSS

Leave a Reply

For spam filtering purposes, please copy the number 5179 to the field below: