Backup Aruba config using Expect

In this test, I am using MC3400 as an example
I install tftp server and expect in Ubuntu, so that I can set cronjob to backup every week

DIAGRAM
-MC3400
ip: 10.0.10.243
P: Password
Enable password: enable
-UBUNTU
ip: 10.0.10.70

UBUNTU
-set correct timezone
# timedatectl set-timezone Asia/Jakarta

-Install TFTP Server
# apt-get install tftpd-hpa
# mkdir /tftpboot
# chmod -R 777 /tftpboot
# chown -R nobody /tftpboot

# cat /etc/default/tftpd-hpa
TFTP_USERNAME=”tftp”
TFTP_DIRECTORY=”/tftpboot”
TFTP_ADDRESS=”0.0.0.0:69″
TFTP_OPTIONS=”-s -c -l”

# service tftpd-hpa restart

-install tftp client to test upload file is working
# apt-get install tftp
# touch test.txt
# tftp 10.0.10.70
tftp> put test.txt
# ls /tftpboot
file test.txt should be there

-Install AutoExpect
# apt-get install expect-dev -y

-create backup script
# cat backup-aruba.sh
#!/usr/bin/expect -f
set DATE [exec date +%Y%m%d%H%M]
spawn ssh admin@10.0.10.243
expect “password:”
send — “Password\r”
expect “>”
send — “enable\r”
expect “Password:”
send — “enable\r”
expect “#”
send — “copy running-config tftp: 10.0.10.70 $DATE-config.cfg\r”
send — “tar logs tech-support\r”
send — “copy flash: logs.tar tftp: 10.0.10.70 $DATE-logs.tar\r”
send — “backup flash\r”
send — “copy flash: flashbackup.tar.gz tftp: 10.0.10.70 $DATE-flashbackup.tar.gz\r”
send — “copy flash: local-userdb-export tftp: 10.0.10.70 $DATE-local-userdb.bin\r”
send — “exit\r”
send — “exit\r”
expect eof
TO-DO:
1. How to get Aruba hostname (show hostname) and put into Expect variable
2. Need to find out what files need to back up in CPPM and VMC, and what are the commands

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s