|
|
|
|
|
|
Home PageContact MeMAC OS XLinuxLinux Servers Fedora Core 4Linux Servers - CentOSLinux Servers Fedora Core 5Linux Servers Fedora Core 7Linux Servers Fedora 8OpenWRTNSLU2LinuxClusterHardware Hacking ProjectsSpeaker Building ProjectsElectronics ProjectsOther Sites |
Status
IntroductionNot much to say here. These scripts are part of my backup scripts. ScriptsThere are two scripts. They have been configured to run as root. Be sure to change the vars to suite your needs. Here's the script to mount the volume.
#!/bin/sh
# Script to Mount NFS volume
#
# set global vars
DSTHOST="backup.company.com" # remote backup host
DSTPATH="/mnt/array1" # set to nfs share point
BKDIR="/private/backup-remote" # mount path of remote backup
# script must be fun by root
if ( test `id -un` != "root" )
then
echo "### script must be run as root"
echo "### backup was terminated"
exit ;
fi
# be sure the network storage device is reachable
echo -n "# Checking for remote host $DSTHOST: "
CHKSRV=`ping -c 3 -q $DSTHOST | grep -c "3 packets received"`
if [ $CHKSRV = "0" ]
then
echo "FAILED"
echo "### cannot connect to the remote backup server"
echo "### the remote host is down"
echo "### backup was terminated"
exit
fi
echo "OK"
# setup the mount point for the backup
echo -n "# Checking for mount point $BKDIR: "
if [ ! -d "$BKDIR" ]
then
echo "DOES NOT EXSIST"
echo -n "# Creating $BKDIR: "
mkdir "$BKDIR"
if [ $? -ne 0 ]
then
echo "FAILED"
echo "### Could not create the backup mount point."
echo "### No backup occured"
exit
fi
echo "OK"
else
echo "OK"
fi
# connect to the network storage device
echo -n "# Mounting remote directory $BKDIR: "
mount -t nfs "$DSTHOST:$DSTPATH" "$BKDIR"
if [ $? -ne 0 ]
then
echo "FALED"
echo "### could not mount the remote directory"
echo "### no backup occured"
exit
fi
echo "OK"
Here's the script to unmount the volume #!/bin/sh # # set global vars BKDIR="/private/backup-remote" # mount path of remote backup # unmount the remote directories echo -n "# unmounting remote directory $BKDIR: " umount $BKDIR if [ $? -ne 0 ] then echo "FAILED" echo "### there was a problem unmounting the directory" else echo "OK" fi sleep 3 # remove the mount points echo -n "# removing mount point $BKDIR: " rmdir $BKDIR echo "OK" ConclusionHope you find these scripts usefull. Comments |