当前位置:Gxlcms > mysql > mysql远程备份并解决编码问题脚本_MySQL

mysql远程备份并解决编码问题脚本_MySQL

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

bitsCN.com

#!/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 {} /;

本文出自 “学习要永恒” 博客

bitsCN.com

人气教程排行