Here is a script that I have been working on to automate backup and figured I would share. Went through a lot of trial and error with trying to do this in Python and found it is just easier to do with Tcl\Expect. Maybe it will help someone or give someone some ideas on how to improve it to make it work better for them. I run this in a cron job. name the script whatever you like and add execute permissions and it should work. Please share ideas imporvements etc...
#!/usr/bin/expect
#CF Aruba backup running confug 7-11-13
# Spawn ssh
spawn ssh admin@your_host
sleep 2
#Catch the password prompt and send supplied password
expect {
"word:" {send "yourpass\r"}
}
sleep 1
#Get into enable mode and issue the command to backup configuration
expect {
"*>" {send "en\r"}
}
sleep 1
expect {
"*word:" {send "enablepass\r"}
}
sleep 1
expect {
"#" {send "copy running-config tftp: ip.of.tftp runn-conf-control1.txt \r"}
}
sleep 10
# Exit cleanly
expect {
"*#" {send "exit\r"}
}
sleep 1
expect {
"*>" {send "exit\r"}
}
sleep 1