reason
In this era full of data support , Its safety is important , No one can guarantee that the service provider or hardware will not have an accident , This leads to data loss .
Script
The following is an extremely simple site backup script , Please change the specific parameters as required .
date=$(date + %F)mkdir $date && cd $datetar -cpzf "blog_$date.tgz" /wwwmysqldump -uroot -p blog > blog_$date.sql
Code language: PHP (php)tar Parameter description
- -c Create Archive
- -p Keep the original permissions
- -z Use gzip
- -f Specify the archive file
- /www Site root path
mysqldump Parameter description
- -uroot root For database users
- -ppassword ( Explicit ) or -p ( Interaction ) password
- blog Database name
- > xxx.sql Export backup to xxx.sql file
Tips: You can set cron Do it regularly .









