站点备份脚本

安装一个lftp
yum -y install lftp

每天自动备份数据库
#!/bin/bash

/usr/local/mysql/bin/mysqldump -uusername -ppassword --databases blog > /home/wwwroot/backup/databackup_$(date +%Y%m%d).sql
tar zPcf /home/wwwroot/backup/databackup_$(date +%Y%m%d).sql.tar.gz /home/wwwroot/backup
/usr/bin/lftp -u ftpusername,ftppassword ftpip/backup -e "put /home/wwwroot/backup/databackup_$(date +%Y%m%d).sql.tar.gz;exit"
rm -r /home/wwwroot/backup/*

chmod +x dbbackup.sh
crontab �Ce
0 0 * * * sh /usr/local/nginx/conf/dabackup.sh //每天0点0分时自动运行

每周自动备份网站数据
#!/bin/bash

tar zPcf /home/wwwroot/backup/blogbackup_$(date +%Y%m%d).tar.gz /home/wwwroot/
/usr/bin/lftp -u ftpusername,ftppassword ftpip/backup -e "put /home/wwwroot/backup/blogbackup_$(date +%Y%m%d).tar.gz;exit"
rm -r /home/wwwroot/backup/*

chmod +x blogbackup.sh
crontab �Ce
0 0 * * 1 sh /usr/local/nginx/conf/blogbackup.sh //每周备份一次数据

你可能感兴趣的:(数据库,local,p,databases,cccccc)