程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> 同步數據庫自動化腳本

同步數據庫自動化腳本

編輯:MySQL綜合教程

同步數據庫自動化腳本   #!/bin/sh  www.2cto.com     read -p "Please keyin your ssh host:" -t 30 host_ip read -p "Please keyin your ssh user:" -t 30 username read -p "Please keyin your ssh pass:" -t 30 password read -p "Please keyin your sync table list,separated by spaces:" -t 30 table_list   datetime=`date +%Y%m%d%H%M%S` src_file="/tmp/data_$datetime.sql" tar_file="/tmp/data_$datetime.tar.gz"   mysqldump -h127.0.0.1 -uroot -ppass database_name $table_list > $src_file tar czvf $tar_file $src_file ./expect_scp.sh $host_ip $username $password $tar_file   expect_scp.sh代碼  www.2cto.com     #!/tools/bin/expect set timeout 10 set host [lindex $argv 0] set username [lindex $argv 1] set password [lindex $argv 2] set src_file [lindex $argv 3] #set dest_file [lindex $argv 4] spawn scp $src_file $username@$host:/home/$username   expect { "(yes/no)?" { send "yes\n" expect "*assword:" { send "$password\n"} } "*assword:" { send "$password\n" } } expect "100%" expect eof  

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved