Linux下自动还原MySQL数据库的Shell脚本
创建shell脚本topjui_source.exp,内容如下:
#!/usr/bin/expect
spawn echo "###### running... ######"
spawn echo $argv0
spawn echo $argv1
set timeout 30
spawn mysql -uroot -p123456
set timeout 30
expect {
"hi" { send "You said hi\n"}
"hello" { send "Hello yourself\n"}
"bye" { send "That was unexpected\n"}
"mysql>" { send "use demo_topjui_com\r"}
}
expect {
#"mysql>" {send "source /home/backup/mysql/topjui/topjui.sql\r"}
}
expect "mysql>"
send "exit\r"
interact
加入到定时计划中,每5分钟自动还原一次topjui数据库:
*/5 * * * * /usr/bin/expect /home/shell/topjui_source.exp > /home/shell/log/topjui_source.log 2>&1
作者:小策一喋
邮箱:xvpindex#qq.com
出处:http://www.cnblogs.com/xvpindex/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。如果觉得本文对您有益,欢迎点赞、欢迎探讨。本博客来源于互联网的资源,若侵犯到您的权利,请联系博主予以删除。

浙公网安备 33010602011771号