mysql远程备份并解决编码问题脚本
#!/bin/bash
IP=192.168.0.198
mysqlpath=/usr/local/mysql/bin
variables=`$mysqlpath/mysql -u root -pmima -h$IP -e" show variables like 'character\_set\_%';" |awk '{print$2}' |sed -n '4'p`
$mysqlpath/mysqldump -uroot -pmima -h$IP --default-character-set=$variables keyword_ad>/back/mysqldb/s198db/keyword_ad_$(date +%Y%m%d).sql;
$mysqlpath/mysqldump -uroot -pmima -h$IP --default-character-set=$variables mysql>/back/mysqldb/s198db/s198mysql_$(date +%Y%m%d).sql;
sleep 180s
cd /back/mysqldb/s198db/
/bin/tar zcf keyword_ad_$(date +%Y%m%d).tar.gz keyword_ad_$(date +%Y%m%d).sql
/bin/tar zcf s198mysql_$(date +%Y%m%d).tar.gz s198mysql_$(date +%Y%m%d).sql
sleep 60s
/usr/bin/find /back/mysqldb/s198db/ -name "*.tar.gz" -mtime +5 -exec rm -rf {} \;
sleep 60s
/usr/bin/find /back/mysqldb/s198db/ -name "*.sql" -mtime +1 -exec rm -rf {} \;
本文出自 “学习要永恒” 博客
相关新闻>>
- 发表评论
-
- 最新评论 更多>>