当前位置:网站首页>Simple site backup shell script

Simple site backup shell script

2022-06-10 16:59:00 Starx's

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 .

原网站

版权声明
本文为[Starx's]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101601317301.html