#!/bin/sh ##### Backup www, sql & mail ##### 15/04/2010 #### Bennie Coetzer #### ############################################################################## ########################## #Declare all the variables ########################## ########################## #Initial Backup Variables ########################## folder=`date "+%Y/%Y-%m-%d"` yr=`date "+%Y"` wpath=/usr/local/www wtpath=/usr/home/backup/$folder/www.tar.gz squsern=<INSERT SQL USERNAME> sqpassw=<INSERT SQL PASSWORD> dbp=/home/backup/$folder/mysql.dmp mlpath=/usr/home/vmail mtpath=/usr/home/backup/$folder/vmail.tar.gz mispath=/usr/local/etc mistpath=/usr/home/backup/$folder/etc.tar.gz getpath=/usr/home/backup/getmail targetpath=/usr/home/backup/$folder/getmail.tar.gz ########################## #Samba Backup Variables ########################## samuser=<SAMBA USERNAME> sampath=<SAMBA FOLDER NAME> samhost=<SAMBA HOST NAME> mpath=/usr/home/backup/mountme bname=mailserver sycname=/usr/home/backup/mountme/mailserver/`date -v-8d "+%Y-%m-%d"` ########################## #WinSMS Backup Variables ########################## smsuser=<SMS USERNAME> smspass=<SMS PASSWORD> smsmsg="Server%20backup%20has%20been%20completed%20succesfully" smsnumbers=<NUMBERS TO SMS> ########################## # Start Initial Script ########################## mkdir -p /usr/home/backup/$folder echo $folder Created succesfully ########################## #Backup www,sql,vmail & etc ########################## echo Backing up www directory... /usr/bin/tar -czf $wtpath $wpath echo Backing up SQL databases... /usr/local/bin/mysqldump -u $squsern -p$sqpassw --all-databases > $dbp echo Backing up E-mails.... /usr/bin/tar -czf $mtpath $mlpath #zip -r $mtpath $mlpath echo Backing up etc folder... /usr/bin/tar -czf $mistpath $mispath echo Backing up Getmail folder... /usr/bin/tar -czf $targetpath $getpath ########################## #Mount, Copy, Unmount, RM ########################## echo Moving files from server to backup directory... /usr/sbin/mount_smbfs -N //$samuser@$samhost/$sampath $mpath/ /bin/cp -rv /usr/home/backup/$folder $mpath/$bname echo Deleting obsolete files... /bin/rm -rf /usr/home/backup/$folder /bin/rm -rf /usr/home/backup/$yr /bin/rm -rf $sycname /sbin/umount $mpath /usr/local/bin/tree /usr/home/backup echo If there were no errors, congradulations! Backup complete ########################## #WinSMS Script ########################## curl "http://www.winsms.co.za/api/batchmessage.asp?User=$smsuser&Password=$smspass&Delivery=No&Message=$smsmsg&Numbers=$smsnumbers;" echo SMS Report sent to $smsnumbers ######################### #############################################################################
Happy Coding :)
Edited by DEViANT, 16 October 2010 - 11:53 AM.


Sign In
Create Account


Back to top









