Toto je starší verze dokumentu!
Obsah
Zálohování
backup.sh
#!/bin/sh ARCHIVE="sw-backup.tar.gz" IP="10.163.8.11 10.163.8.12 10.170.2.35 10.170.2.39" rm -f /srv/tftp/*.log for ip in $IP; do echo $ip /usr/bin/expect -f <<EOD set timeout 20 spawn telnet $IP expect "ame:" send "username\r" expect "assword:" send "password\r" expect "#" send "copy running-config tftp://ip.ad.re.sa/sw-$IP.cfg\r" expect "?" send "\r" expect "?" send "\r" expect "#" EOD done tar -zcf /tmp/$ARCHIVE /srv/tftp/* uuencode /tmp/$ARCHIVE $ARCHIVE | mail -s "Switches backup" email@email.cz rm -f /tmp/$ARCHIVE
backupsw.exp
#!/usr/bin/expect -f set timeout 20 # tftp server set tftp "10.163.7.180" # router user name set name "atmin" # router password set pass "heslo" # start telnet spawn telnet [lindex $argv 0] # send username and password expect "ame:" send "$name\r" expect "Password:" send "$pass\r" expect "#" send "copy running-config tftp://$tftp/sw-[lindex $argv 0].cfg\r" expect "?" send "\r" expect "?" send "\r" expect "#"
