#!/bin/bash
#Shell Command For Backup MySQL Database Everyday Automatically By Crontab
#Author : Linsong
#Date : 2011-10-11
service mysqld stop
filedate=`date +%Y%m%d`
mkdir -p /home/backup/$filedate
tar -zcvf /home/backup/$filedate/web.tar.gz /var/www/HTML/web/
tar -zcvf /home/backup/$filedate/mysql.tar.gz /var/lib/mysql/
chown -R www:www /home/backup/$filedate
rm -rf /etc/httpd/conf/httpd-for-backup.conf
echo "<VirtualHost *:80>" >> /etc/httpd/conf/httpd-for-backup.conf
echo "ServerAdmin webmaster@dummy-host.example.com" >> /etc/httpd/conf/httpd-for-backup.conf
echo "DocumentRoot /home/backup/$filedate" >> /etc/httpd/conf/httpd-for-backup.conf
echo "ServerName download.web.com" >> /etc/httpd/conf/httpd-for-backup.conf
echo "ErrorLog logs/download.web.com-error_log" >> /etc/httpd/conf/httpd-for-backup.conf
echo "CustomLog logs/download.web.com-access_log common" >> /etc/httpd/conf/httpd-for-backup.conf
echo "</VirtualHost>" >> /etc/httpd/conf/httpd-for-backup.conf
service mysqld start
service httpd restart