当前位置:Gxlcms > mysql > Mysql完全备份_MySQL

Mysql完全备份_MySQL

时间:2021-07-01 10:21:17 帮助过:6人阅读

bitsCN.com 1.查看mysql上都有哪些库
mysql> show databases G
*************************** 1. row ***************************
Database: information_schema
*************************** 2. row ***************************
Database: mysql
*************************** 3. row ***************************
Database: test
3 rows in set (0.00 sec)
2.执行完全备份
sh back.sh
back.sh
#!/bin/sh
export back_dir=/data/bak
export pass="123"
export mysql_dir=/usr/local/mysql-5.1.56
for i in $(mysql -uroot -p$pass -e show databases G | grep Database | cut -d: -f2)
do
$mysql_dir/bin/mysqldump --opt $i -p$pass --skip-lock-tables>$back_dir/$i.$(date +%Y%m%d).sql
done
#use fetion to notice dba
LD_LIBRARY_PATH=/usr/lib /usr/local/fetion/fetion --mobile=159xxxx3240 --pwd=123456 --to=159xxxx3240 --msg-utf8=mysql backup is success !
3.计划任务
crontab -e
0 3 * * * sh /usr/bin/back.sh bitsCN.com

人气教程排行