Home Page

Contact Me

MAC OS X

Linux

Linux Servers Fedora Core 4

Linux Servers - CentOS

Linux Servers Fedora Core 5

Linux Servers Fedora Core 7

Linux Servers Fedora 8

OpenWRT

NSLU2

LinuxCluster

Hardware Hacking Projects

Speaker Building Projects

Electronics Projects

Other Sites





MACosX /

Status

  • DONE

Introduction

Not much to say here. These scripts are part of my backup scripts.

Scripts

There 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"

Conclusion

Hope you find these scripts usefull.

Comments

Add Comment 
Sign as Author 
Enter code 115


Google
 
Theme by Richard Camp
(C) Copyright 1996-2007 by Richard Camp All rights reserved