Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ################ Global Configs ################
- BACKUPDRIVE='/dev/sdb1/'
- MOUNTPOINT='/backup'
- MYSQLPASSWORD='mysqlpassword'
- TEMPPATH='/backup/temp'
- ###############################################
- ############## Local Backup Configs ###########
- DAILYBACKUPS=1
- DAILYPATH='/backup/ElectServer01/Automated/Daily/'
- DAYSTOKEEP=7
- WEEKLYBACKUPS=1
- WEEKLYPATH='/backup/ElectServer01/Automated/Weekly/'
- WEEKSTOKEEP=4
- MONTHLYBACKUPS=1
- MONTHLYPATH='/backup/ElectServer01/Automated/Monthly/'
- MONTHSTOKEEP=12
- ###############################################
- ############ Remote Backup Configs ############
- REMOTEBACKUPS=1
- REMOTEUSER='ElectServer01'
- REMOTESERVER='ElectServer01'
- REMOTEPATH='ElectServer01'
- ###############################################
- ########## Backup To The Temp Folder ##########
- mkdir $TEMPPATH
- cp -dRu --preserve=ownership /var/www $TEMPPATH/Apache
- mkdir $TEMPPATH/MySQL
- mysqldump --all-databases --password=$MYSQLPASSWORD > $TEMPPATH/MySQL/dump.mysql
- mkdir $TEMPPATH/OpenLDAP
- slapcat -v -l $TEMPPATH/OpenLDAP/dump.ldif
- mkdir $TEMPPATH/SAMBA
- cp -dRu --preserve=ownership /etc/samba/smb.conf $TEMPPATH/SAMBA/smb.conf
- mkdir $TEMPPATH/ProFTPD
- cp -dRu --preserve=ownership /etc/proftpd/proftpd.conf $TEMPPATH/ProFTPD
- cp -dRu --preserve=ownership /etc/proftpd/ldap.conf $TEMPPATH/ProFTPD
- cp -dRu --preserve=ownership /etc/proftpd/modules.conf $TEMPPATH/ProFTPD
- cp -dRu --preserve=ownership /home $TEMPPATH/Home
- ###############################################
- ######### Do daily backups if needed ##########
- if [DAILYBACKUPS=1]; then
- cp $TEMPPATH $DAILYPATH/$(date +%d-%m-%Y)/
- fi
- ###############################################
- ### Do weekly backups if needed on a Sunday ###
- if [WEEKLYBACKUPS=1]; then
- if [ `date +%a` = Sun ]; then
- cp -dRu --preserve=ownership $TEMPPATH $WEEKLYPATH/$(date +%d-%m-%Y)/
- fi
- fi
- ###############################################
- ### Do monthly backups if needed on the 1st ###
- if [MONTHLYBACKUPS=1]; then
- if [ `date +%d` = 01 ]; then
- cp -dRu --preserve=ownership $TEMPPATH $MONTHLYPATH/$(date +%d-%m-%Y)/
- fi
- fi
- ###############################################
- ########## Do remote backup if needed #########
- if [REMOTEBACKUPS=1]; then
- rsync –ave ssh $TEMPPATH $REMOTEUSER@$REMOTESERVER:$REMOTEPATH
- fi
- ###############################################
- ############ Delete the Temp Files ############
- rm -R $TEMPPATH
- ###############################################
- ########### Remove Older Daily Backups ########
- find $DAILYPATH -type d -mtime +$DAYSTOKEEP
- ###############################################
- ########## Remove Older Weekly Backups ########
- find $WEEKLYPATH -type d -mtime +$(($WEEKSTOKEEP*7))
- ###############################################
- ########## Remove Older Monthly Backups #######
- find $WEEKLYPATH -type d -mtime +$(($MONTHSTOKEEP*31))
- ###############################################
Add Comment
Please, Sign In to add comment