#!/bin/bash ####SET YOUR PATHS HERE#### backup="/mnt/fs/Backup" webpath="/var/www/html" sqldumppath="/usr/bin/mysqldump" ####DO YOU WANT ROOT TO ONLY BE ABLE TO RUN THIS?#### #### 1 = yes #### 0 = no ############ rootonly="1" if [ $rootonly == "1" ]; then if [ "$UID" != "0" ]; then echo "Must be root to run this script!" exit fi fi ####CHECK FOR BACKUP DIR### if [ ! -x $backup ]; then echo "Backup directory does not exist!" exit 0 fi ####CHECK FOR EXISTING BACKUP TODAY#### if [ -f $backup/$(date +%m%d%y).tar.gz ]; then echo "A backup file for today already exist!" exit 0 fi ######BACKUP DATABASE###### RETVAL=0 cur="$backup/$(date +%m%d%y)" mkdir $cur mkdir $cur/SQL mkdir $cur/WEB $sqldumppath -A > $cur/SQL/$(date +%m%d%y).sql ######BACKUP WEBSITE####### /bin/tar -cf $cur/WEB/$(date +%m%d%y).tar $webpath /bin/gzip $cur/WEB/$(date +%m%d%y).tar #####ADD ANY ADDITIONAL BACKUPS HERE############# # # ################################################# #####CREATE BACKUP FILE##### /bin/tar -cf $backup/$(date +%m%d%y).tar $cur /bin/gzip $backup/$(date +%m%d%y).tar #####REMOVE JUNK FILES##### /bin/rm -rf $cur /bin/rm -rf $backup/$(date +%m%d%y).tar exit $RETVAL