1、备份数据库脚本
在/root/目录下建立脚本
vim dbbackup-vpser.sh
#./bin/bash
/usr/local/mysql/bin/mysqldump -usqlusername -psqlpassword –databases vpser > /home/wwwroot/backup/vpser_$(date +%Y%m%d).sql
tar zPcf /home/wwwroot/backup/vpser_$(date +%Y%m%d).sql.tar.gz /home/wwwroot/backup
/usr/bin/lftp -u ftpuser,ftppassword bakup.vpser.com/backup -e “put /home/wwwroot/backup/vpser_$(date +%Y%m%d).sql.tar.gz;exit”
rm -rf /home/wwwroot/backup/*
2、备份blog文件脚本
在/root/目录下建立脚本
vim blogbackup-vpser.sh
#!/bin/bash
tar zPcf /home/wwwroot/backup/vpserblogbackup_$(date +%Y%m%d).tar.gz /home/wwwroot/vpser.com/
/usr/bin/lftp -u ftpuser,ftppassword bakup.vpser.com/backup -e “put /home/wwwroot/backup/vpserblogbackup_$(date +%Y%m%d).tar.gz;exit”
rm -rf /home/wwwroot/backup/*
3、自动执行
crontab –e
30 0 * * * sh /root/dbbackup-vpser.sh
30 1 * * 1 sh /root/blogbackup-vpser.sh