Linux下两个服务器互备脚本
操作方法
- 01
rq=`date +%Y%m%d`rq1=` date "-d 1 day ago" "+%Y%m%d" `rm_ipAddr=192.168.1.* #备份IPhost_id="filebak90"if test -e filebak_90_$rq1.shthen rm -f filebak_90_$rq1.shfirunName=$host_id.shecho "#!/usr/bin/expect" > /edu-backup/shell/$runName echo "set password "filebak#90#filebak"" >> /edu-backup/shell/$runNameecho "spawn "scp /edu-backup/databak/*$rq*.tar.gz filebak@$rm_ipAddr:/usr/xxtsrc/"" >> /edu-backup/shell/$runNameecho "sleep 30" >> /edu-backup/shell/$runNameecho "expect "filebak@$rm_ipAddr's password:"" >> /edu-backup/shell/$runNameecho "send "$password"" >> /edu-backup/shell/$runNameecho "set timeout 5000" >> /edu-backup/shell/$runNameecho "send "exit"" >> /edu-backup/shell/$runNameecho "expect eof" >> /edu-backup/shell/$runNamechmod 777 /edu-backup/shell/$runName/edu-backup/shell/$runNameecho "`date`" "to90filebak success" >> /edu-backup/shell/filebak_log .