This is a simple solution for backup running config on Cisco switch&router. Before you start to backup you should install
- tftp service
- expect command
After installed tfpt service & expect command. You can test to backup script by my example script below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/usr/bin/expect set username "USERNAME" set password "PASSWORD" spawn telnet IP-Core-SWITCH # -- Authenticate -- # expect "Username: "; send "$username\r"; expect "Password: "; send "$password\r"; # -- Copy file to TFTP Server -- # expect "*#"; send "copy flash:config.text tftp://IP-Backup-Server/config.text\r"; expect "*\?"; send "\r"; expect "*\?"; send "\r"; expect "*#"; send "exit\r"; interact |
After you create a script complete, you should change a permission of this script to 700.