Summary: Backup2Novell automates the process of archiving a folder or file, and then adding it to a specific folder on a Novell server. It uses 7zip for Unix for it’s archives.
Requirements:
- ncpfs
- p7zip
Code:
#!/bin/bash ##By Blake Johnson USERNAME="USERNAME" ##Novell Username (this is case sensative to whatever the mounted directory will use.) CONTEXT="something.something" ##Novell Context w/ out beginning dot. PASSWORD="PASSWORD" ##Novell Password BACKUPNAME="public_html" ##This must not contain any special characters. BACKUPSOURCE="${HOME}/public_html/" ##What file or folder would you like to back up? SERVERNAME="SERVERNAME" ##The name of the remote Novell server. SERVERADDRESS="SERVERIP" ##The address of the remote Novell server. MOUNTDIRECTORY="${HOME}/mnt/MOUNTPOINT" ##The directory where you want to mount the Novell share. BACKUPHOME="${MOUNTDIRECTORY}/STAFF/USERS/Folders/${USERNAME}" ##Directory where you are first able to write. BACKUPFILENAME="${BACKUPNAME}.`date +%Y%m%d`.7z" ##This must not contain any special characters. BACKUPDESTINATION="${MOUNTDIRECTORY}/Folders/${USERNAME}/.backup/${BACKUPNAME}" ##Where should the backup file be placed? ##Write Date & Time to Log File echo "-------------------------------------" > ~/.Backup2Novell.log echo "`date +%B %d, %Y`" >> ~/.Backup2Novell.log echo "-------------------------------------" >> ~/.Backup2Novell.log echo -n "Checking if the ncpfs package is installed... " if [ -x /usr/bin/ncpmount ] ; then echo -e "33[1;32mOK!" echo -e "33[0m" ##Log in to Novell Share and mount it. echo -n "Mounting Novell Share... " echo "ncpmount -S ${SERVERNAME} -A ${SERVERADDRESS} -U ${USERNAME}.${CONTEXT} -P ${PASSWORD} ${MOUNTDIRECTORY}" >> ${HOME}/.Backup2Novell.log ncpmount -S ${SERVERNAME} -A ${SERVERADDRESS} -U ${USERNAME}.${CONTEXT} -P ${PASSWORD} ${MOUNTDIRECTORY} >> ${HOME}/.Backup2Novell.log ##Check to see if userfolder exists. if [ -d ${BACKUPHOME} ] ; then echo -e "33[1;32mOK!" echo -e "33[0m" echo "Backing up ${BACKUPSOURCE}" echo "Please Wait..." ##Compress and archive backup source and send it to the Novell Folder. echo "7z a "${BACKUPDESTINATION}/${BACKUPFILENAME}" "${BACKUPSOURCE}" >> ${HOME}/.Backup2Novell.log" >> ${HOME}/.Backup2Novell.log 7z a "${BACKUPDESTINATION}/${BACKUPFILENAME}" "${BACKUPSOURCE}" >> ${HOME}/.Backup2Novell.log ##Check to see if the file was written. if [ -e "${BACKUPDESTINATION}/${BACKUPFILENAME}" ] ; then echo -e "~/public_html Backup 33[1;32mSuccessful" echo -e "33[0m" else echo -e "~/public_html Backup 33[1;31mFailed" echo -e "33[0mUnable to write to destination" fi ##Unmount and log out of the Novell share. echo -n "Unmounting Novell Share... " echo "ncpumount ${MOUNTDIRECTORY}" >> ${HOME}/.Backup2Novell.log ncpumount ${MOUNTDIRECTORY} >> ${HOME}/.Backup2Novell.log if [ -d ${BACKUPHOME} ] ; then echo -e "33[1;31mFailed!" echo -e "33[0m" else echo -e "33[1;32mOK!" echo -e "33[0m" fi else echo -e "33[1;31mFailed!" echo -e "33[0m" fi else echo -e "33[1;31mFailed." echo -e "33[0mYou must install the ncpfs package in order for this script to work." echo fi echo "This script will self-destruct in 5 seconds." sleep 5s