Linux 备份数据库和移除历史备份脚本
#!/bin/bash logfile='/alidata1/bak/bakdata.log' bakdir='/alidata1/bak/' year=`date "+%Y"` today=`date "+%j"` prev7date=`date -d "-8 day" "+%Y%m%d"`; bakdate=`date "+%Y%m%d"` bakfile=${bakdir}${bakdate}.dbname.sql bakprevfile=${bakdir}${prev7date}.dbname.sql if [[ -f $bakprevfile ]]; then echo "删除一周前的文件" >> $logfile rm -f $bakprevfile fi mysqldump -uroot -p'password' dbname > $bakfile
posted on 2021-07-26 09:49 loveking_阳 阅读(55) 评论(0) 编辑 收藏 举报