您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

同步数据库自动化脚本_MySQL

2024/4/30 5:20:01发布19次查看
bitscn.com
同步数据库自动化脚本
#!/bin/sh  www.bitscn.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.bitscn.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
bitscn.com
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product