Listing 1 fssnap.sh
#!/usr/bin/bash
HOST=`uname -n`
BACKINGSTORE=/share/backingstore/$HOST
FSSNAP=/usr/lib/fs/ufs/fssnap
snap_mount()
{
SLASH=/
MOUNTPT=/snap/${FS//$SLASH/_}
[ -d $BACKINGSTORE ] || mkdir $BACKINGSTORE
SNAPDEV=`$FSSNAP -o bs=$BACKINGSTORE,unlink $FS`
[ -d $MOUNTPT ] || mkdir $MOUNTPT
mount -o ro $SNAPDEV $MOUNTPT
}
if [ "X$1" = "X-d" ] ; then
#Delete snapshots
for SNAPDEV in `$FSSNAP -i -o blockdevname` ; do
umount $SNAPDEV
$FSSNAP -d $SNAPDEV
done
else
#Create snapshots
for FS in `df -F ufs | awk '{print $1}'` ; do
case $FS in
#exclude filesystems we never backup
/dumps|/export/backingstore|/export/swap) ;;
#Stop xntpd while snapshotting / and /var
/|/var) /etc/init.d/xntpd stop; snap_mount; /etc/init.d/xntpd start;;
*) snap_mount ;;
esac
done
fi
|