Linux 备份MySQL 并压缩

#!/bin/bash bakdir=/root/kkk/bak/ year=`date +%Y` month=`date +%m` day=`date +%d` hour=`date +%k` min=`date +%M` dirname=$bakdir$year$month$day.sql.gz #mysqldump testdb -uroot -p1234 | gzip>$dirname echo $dirname str=$(date +%Y%m%d --date '30 days ago') rm $bakdir$str.sql.gz

备份当天,并且删除30天前的

你可能感兴趣的:(Linux)