Thursday, February 15, 2007

Mount the Backup Disk to Recover a File or Directory

Here's an example of mounting and umounting a slice on the backup hard drive. In this example, a configuration file and a home directory will be recovered. I'm copying both items to /tmp on the active disk to review.

Assume active disk is /dev/dsk/c0t0d0s0
#cd /
#mount /dev/dsk/c0t1d0s0 /mnt
#cp -p /mnt/etc/someconfig.cfg /tmp
#mkdir /a
#mount /dev/dsk/c0t1d0s6 /a
#cp -pr /a/USERS/esofthub /tmp
#umount /mnt
#umount /a
#rmdir /a
#cd /tmp

2 comments:

UX-admin said...

Tip:

While `cp -p` will preserve permissions, sparse files, symbollic and hard links will be handled incorrectly. Because of this, it is recommended to use the following to copy large amounts of data from one slice (or disk) to another:


mkdir /mnt/src/
mkdir /mnt/dst/
mount -F ufs -o ro.largefiles /dev/dsk/c#t#d#s# /mnt/src
mount -F ufs -o rw,largefiles,logging /dev/dsk/c#t#d#s# /mnt/dst

cd /mnt/src/
( find . -depth -print | cpio -pvdmu /mnt/dst/ > /tmp/cpio.log ) 2> /tmp/cpio.err
cd
umount /mnt/dst
umount /mnt/src
rm -rf /mnt/src /mnt/dst


And while the above example will also not handle sparse files correctly, as far as I know, short of Joerg Schilling's `star` or perhaps `gtar`, there is really no tool on Solaris that does know how to handle those files; and `gtar` is only recommended for sparse files as the last resort, as he also does not copy them 1:1.

esofthub said...

As always, thanks for the tip ux-admin.