Sunday, February 26, 2012

Bash script to back up configuration of apache2, php5, mysqp, cron*, apt .... -- older configuration (15 days) will be deleted

# Script Function:
# This bash script backups some of the configurations (Depend on Server configurations) that we need and dependent on when you set the cron $
# The db will be saved whereever we want
# Configuration backups older than 15 days will be deleted.
#[Set Backup Directory and Files]
BACKUP_FILES="/etc/apache2/ /etc/mysql/ /etc/apt/ /etc/cron* /etc/network/ /etc/php5/ /etc/fstab /usr/local/bin/"

#[Change Directory]
#[Old Files Deletion Script]
find $BACKUP_PATH -name "*.tar.gz" -mtime +30 -exec rm -f {} \;
#[Stamps the file name with a date]
TIMESTAMP=`date +%y-%m-%d-%H%M`

tar -czPf dmz.$TIMESTAMP.tar.gz $BACKUP_FILES

No comments:

Post a Comment