备份MYSQL脚本
#!/bin/sh # this shell to backup mysql #[email protected] (QQ:1413161683 DuChengJiu) _dbDir=/var/lib/mysql/ _today=`date +%w` _bakDir=/usr/backup/$_today [ ! -d $_bakDir ] && mkdir -p $_bakDir #Create db tar archive #/usr/local/mysql/share/mysql/mysql.server stop service mysqld stop for db in `find $_dbDir -type d|tail -n +2` do echo "Do $db ...." realDb=`echo $db|awk -F / '{print $NF}'` echo "Backup $realDb ......" tar cvf $_bakDir/${realDb}.tar $db || echo "$realDb : 1" >>$_bakDir/backup-error done #/usr/local/mysql/share/mysql/mysql.server start service mysqld start #gzip backup for zip in $_bakDir/*.tar do echo "Compress $zip ........" gzip -f $zip done find $_bakDir -name "*tar" -exec rm -f {} \;
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11