Loading

Sunday, July 26, 2009

Linux shell script backup system configuration httpd mysql apache files

# THE FOLLOWING DIRECTORIES MUST EXIST
# /var/backup
# /var/backup/tmp
# /var/backup/conf
# /var/backup/tmp/conf

# GATHER SYSTEM INFORMATION
cp /etc/php.ini /var/backup/tmp/conf/php.ini
cp /etc/my.cnf /var/backup/tmp/conf/my.cnf
cp /etc/hosts /var/backup/tmp/conf/hosts
rpm -qa > /var/backup/tmp/conf/rpms

# GATHER HTTPD INFORMATION
tar -cvf /var/backup/tmp/conf/etc-http-conf.tar /etc/httpd/conf/

# TAR & COMPRESS ALL INFO
tar -cvf /var/backup/conf/confbak.tar /var/backup/tmp/conf/
gzip -f /var/backup/conf/confbak.tar

# COPY TO DAILY CRONTAB (without # sign) TO RUN EVERY DAY
# cp /root/bin/confbak.sh /etc/cron.daily/


# CLEANUP
rm -rf /var/backup/tmp/conf/*

No comments:

Post a Comment