标签:shel find db2 mysqld 查找 同步 mysq one user
#!/bin/bash#定义日志
exec &> /tmp/mysql_bak.log
echo "mysql bakup begin at ‘date‘"
#对所有数据库进行遍历
for db in db1 db2 db3 db4 db5
do
$mysqldump -u$bakuser -p$passwd $db >$bakdir/$db-$d1.sql
done
对一天前的所有sql文件压缩
find $bakdir/ -type f -name "*.sql" -mtime +1 | xargs gzip
查找一周以前的老文件,并删除
find $bakdir/ -type f -mtime +7 | xargs rm
把当天的备份文件同步到远程
for db in db1 db2 db3 db4 db5
do
rsync -a $bakdir/$db-$d1.sql $remote_dir/$db-$d2.sql
done
echo "mysql backup end at ‘date‘"
标签:shel find db2 mysqld 查找 同步 mysq one user
原文地址:http://blog.51cto.com/13120271/2317880