一段常用db备份脚本



1 #!/bin/bash
2 ### create by yunfei.heyf
3 ### program for backup mysql with mysqldump
4
5
6 BAKDIR="/home/admin/backup"
7 DUMPCMD="/usr/bin/mysqldump -uroot -h127.0.0.1 -pnothing --default-character-set=utf8 --databases "
8 BAKDB="tm"
9 BAKSET="daily_"$(date +%y%m%d%H%M).bak
10
11 ########## del bakset before N days ago
12 find ${BAKDIR} -name "daily*.bak" -ctime +7 -exec rm -f {} \;
13
14
15 $DUMPCMD $BAKDB > $BAKDIR/$BAKSET
16
17 exit 0