Monday, June 18, 2007

Disk to Disk Backup using ufsdump

I was asked the other day how to create a bootable backup disk. In a previous post, I used the dd command to perform this task. However, you can use the ufsdump/ufsrerestore procedure, too. Here are 2 generic scripts, one c shell and the other Bourne shell.

Note: This was done on a Solaris 8 system and in single user mode.

=====================================
C Shell Script
=====================================
#!/bin/csh

foreach myslice ( 0 3 4 )
echo y | newfs /dev/rdsk/c1t1d0s$myslice
end

cd /
foreach myslice ( 0 3 4 )
mount /dev/dsk/c1t1ds$myslice /mnt
cd /mnt
ufsdump 0uf - /dev/rdsk/c1t0d0s$myslice | ufsrestore rf -
rm restoresymtable
cd /
umount /mnt
end

/usr/sbin/installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t1d0s0
mount /dev/dsk/c1t1d0s0 /mnt
sed 's/t0/t1/g' /mnt/etc/vfstab > /var/tmp/vfstab
cp /var/tmp/vfstab /mnt/etc/vfstab
umount /mnt

=====================================
Bourne Shell Script
=====================================
#!/bin/sh

for myslice in 0 3 4
do
echo y | newfs /dev/rdsk/c1t1d0s$myslice
done

cd /
for myslice in 0 3 4
do
mount /dev/dsk/c1t1ds$myslice /mnt
cd /mnt
ufsdump 0uf - /dev/rdsk/c1t0d0s$myslice | ufsrestore rf -
rm restoresymtable
cd /
umount /mnt
done

/usr/sbin/installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t1d0s0
mount /dev/dsk/c1t1d0s0 /mnt
sed 's/t0/t1/g' /mnt/etc/vfstab > /var/tmp/vfstab
cp /var/tmp/vfstab /mnt/etc/vfstab
umount /mnt

No comments: