The importance of Web site backup, believe that every webmaster is know, and now most stationmaster, have used the VPS host, in the Linux operating system, the VPS data backup main is, the website file, the database, the domain name configuration and so on, like the tribe is uses the military elder brother a health installs the package, the operation basically is identical.
Here, we mainly use the script to automate the operation, the contents are as follows:
The code is as follows |
Copy Code |
#!/bin/bash Mysql_user=root #mysql用户名 mysql_pass=123456 #mysql密码 Web_data=/home/web #要备份的网站数据 Vhost=/usr/local/nginx/conf/vhost #域名配置目录 #压缩网站数据 from Www.111cn.net Tar zcf/home/wwwroot/backup/web.tar.gz $WEB _data #压缩域名配置 Tar zcf/home/wwwroot/backup/vhost.tar.gz $VHOST #导出数据库, a database with a compressed file For DB in '/usr/local/mysql/bin/mysql-u$mysql_user-p$mysql_pass-b-n-e ' show DATABASES | Xargs '; Todo (/usr/local/mysql/bin/mysqldump-u$mysql_user-p$mysql_pass ${db} | gzip-9-> ${db}.sql.gz) Done #压缩数据库文件为一个文件 Tar zcf/home/wwwroot/backup/data.tar.gz/home/wwwroot/backup/*.sql.gz Rm-rf/home/wwwroot/backup/*.sql.gz |
Here the tribe needs to be explained that you need to modify the database username, password.
There is also a more important, that is, you need your site path to the original path, otherwise you can not complete all the data backup. Of course, no one is going to make any changes to these paths.
Summary
Web site data Backup is a very important work, if you think your host is not particularly secure, the tribe recommends that you perform a backup operation at least once a week. Like tribal words, basically is a monthly backup, mainly to think of the host is still safe, in addition, like pictures of what they have data.