复制代码 代码如下:
22 3 * * 0 root run-parts /etc/cron.weekly
复制代码 代码如下:
chmod 0755 /etc/cron.weekly/webbackup.sh
复制代码 代码如下:
#!/bin/sh
filename=`date +%Y%m%d`
backup_dir="/root/Dropbox/backup/web"
#delete all files 10 days ago
find $backup_dir -mtime +30 -name "*" -exec rm -rf {} /;
#each user you want backup
users="baidu sina"
for user in ${users}; do
tar zcvf $backup_dir/$user$filename.tar.gz /home/$user/public_html
done
复制代码 代码如下:
#!/bin/sh
dbuser="backup"
dbpassword="youpassword"
datas="db1 db2 db3"
filename=`date +%Y%m%d`
bin_dir="/usr/local/mysql/bin"
backup_dir="/root/Dropbox/backup/mysql"
#delete all files 10 days ago
find $backup_dir -mtime +10 -name "*" -exec rm -rf {} /;
#Do each database backup
for data in ${datas}; do
$bin_dir/mysqldump --opt -u$dbuser -p$dbpassword $data | gzip > $backup_dir/$data$filename.sql.gz
done
新闻热点
疑难解答