#!/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`
时间: 2024-12-05 03:13:35