Announcing goSwitchBackup

Posted by Daniel T. Morgan on Monday Feb 22 2016
In Development, Golang
Tags go, golang, development, switches, ssh, cisco

goSwitchBackup is Go program I wrote, to automate the backing up of Cisco switches over SSH for the network boys in work. It essentially SSHs (can you use it like a verb like that?) into an IP (Which should be the address of a Cisco switch) using the password, once it receives the prompt character it trys to escalate privileges using:

enable
Once it sees the “#” character it then tries to run the backup command:
copy running-config tftp
It will then give the TFTP server address used when the program was invoked, and name the file:

switchBackup-IP-OF-SWITCH-RFC3339timestamp

(I may make this configurable later)

You can check out the code on github here:

https://github.com/plod/goSwitchBackup

Once you run or compile, or just go run the code, pass the -help command for helps with flags.

Any comments or requests for more information please post in the comments below (I am still quite new to Go so any helpful pointers would also be gratefully received).

todo/wishlist:

  • Add potential TFTP server inside the program itself
  • compare previous backup with current backup and send alert of changes (SMTP)
  • Add a verbose switch to echo some of the commented stuff that helps debug issues