站點備份的腳本
安裝一個lftp
yum -y install lftp
每天自動備份數據庫 www.2cto.com
#!/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 –e
0 0 * * * sh /usr/local/nginx/conf/dabackup.sh //每天0點0分時自動運行
每周自動備份網站數據 www.2cto.com
#!/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 –e
0 0 * * 1 sh /usr/local/nginx/conf/blogbackup.sh //每周備份一次數據