时间:2021-07-01 10:21:17 帮助过:32人阅读
#!/bin/bash #备份数据库hz jshuabo sdhuabo name=$(date +%Y%m%d) /alidata/server/mysql-5.1.73/bin/mysqldump -u root -p123456 hz > /root/sqlBackup/hz.$name.sql /alidata/server/mysql-5.1.73/bin/mysqldump -u root -p123456 jshuabo > /root/sqlBackup/jshuabo.$name.sql /alidata/server/mysql-5.1.73/bin/mysqldump -u root -p123456 sdhuabo > /root/sqlBackup/sdhuabo.$name.sql #删除一周之前的备份文件 file_path="/root/sqlBackup" #方法a #rm -rf `find $file_path '*.sql' -mitime 7 -print` > delete.log; #方法b find $file_path -mtime +7 -type f|xargs rm -f #方法c #rm -f `find $file_path -mtime +7 -type f`