Automatic backup of the configuration of an EMC DS300 fibrechannel switch
Like in many cases an Expect script can help to achieve this. The lines 10 and 12 contain the login information for the switch. Line 14 defines the transfer protocol (SCP in this case), the login name, the destination host and the target directory for upload. The password for SCP to the destination host is defined in line 16. It's clear that all accounts only should have the rights absolutely necessary but not more.Expect script
#!/usr/bin/expect
set host [lindex $argv 0]
set timeout 30
if ($argc!=1) {
send_error "Usage: $argv0 Hostname\n"
exit 1;
}
spawn ssh admin@$host
expect "password:"
send "GANZGEHEIM\r"
expect ":admin> "
send "configupload -all -p scp 172.19.3.492,brocadeup,/data/up/brocade/$host.txt\r"
expect "password:"
send "PASSWORD\r"
expect ":admin>"
send "exit\r"
Running the Expect script
To start the Expect script shown above simply use a line in the form of fetch-brocade-config.bash host.na.meThis command can be used as a time driven CRON job of course.