Super simple Linux website backup script Shell

Source: Internet
Author: User

#! /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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.