每天定时备份所有数据库数据库名字在文件:dbfile中,定时清除3天前的备份文件
#!/bin/bash dd=`date +%Y%m%d` backup_dir="/usr/soft/crontabshell/" username="uname" password="password" for dbname in `cat ${backup_dir}dbfile` do nohup /usr/local/MysqL/bin/MysqLdump -u${username} -p${password} -B $dbname > ${backup_dir}${dbname}_${dd}.sql 2>/dev/null & ####echo $? done find $backup_dir -ctime +3 -name "*.sql" -exec rm -rf {} \;