Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Function perpose;
- # To check if the nas drive is mounted
- # if not, mount it, if it is, move onto the rsync
- check_mount()
- {
- command=$(mount | grep $NAS_MOUNTDIR | cut -d\ -f3)
- if [ "$command" != "$NAS_MOUNTDIR" ]
- then
- nas_mount
- else
- echo "$NAS_MOUNTDIR already mounted"
- rsync_nas
- fi
- # exit 0
- }
- # Function perpose;
- # to mount the NAS cifs share to a local directory
- #
- nas_mount()
- {
- sudo mount -t cifs //$NAS_SERVER/$NAS_PATH -o username=$NAS_USER,password=$NAS_PASS /$NAS_MOUNTDIR
- if [ ${PIPESTATUS[0]} -ne 0 ] ; then
- echo -e "Mounting of cifs share from $NAS_SERVER has failed $(date +%R)" | log
- exit
- else
- echo -e "Mounting of cifs share from $NAS_SERVER sucessful, moving onto rsync $(date +%R)" | log
- rsync_nas
- fi
- }
- # Function perpose
- # to remove the cif's mount
- #
- nas_umount()
- {
- sudo umount /$NAS_MOUNTDIR
- }
- # script perpose;
- # take a local copy of the backup directory (including scanned archives) and
- # rsync them to the mount cifs share mounted with the nas_mount function
- rsync_nas()
- {
- sudo rsync -vauz $BACK_DIR/* /$NAS_MOUNTDIR 2>&1 > $LOG_DIR/rsync.$(datsudo e +%Y%m%d).log
- if [ ${PIPESTATUS[0]} -ne 0 ] ; then
- echo -e "rsync of $BACK_DIR has failed $(date +%R)" | log
- exit
- else
- echo -e "rsync of $BACK_DIR sucessful $(date +%R)" | log
- fi
- }
- # Add the below Var's
- # Add $NAS_SERVER=10.3.60.60
- # Add $NAS_USER=su
- # Add $NAS_PASS=*****
- # Add $NAS_PATH=comrad
- # Add $NAS_MOUNTDIR=/mnt/
- # Add $RSYNC_NAS=YES
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement