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

P: Password
Enable password: enable

-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_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
tftp> put test.txt
# ls /tftpboot
file test.txt should be there

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

-create backup script
# cat
#!/usr/bin/expect -f
set DATE [exec date +%Y%m%d%H%M]
spawn ssh admin@
expect “password:”
send — “Password\r”
expect “>”
send — “enable\r”
expect “Password:”
send — “enable\r”
expect “#”
send — “copy running-config tftp: $DATE-config.cfg\r”
send — “tar logs tech-support\r”
send — “copy flash: logs.tar tftp: $DATE-logs.tar\r”
send — “backup flash\r”
send — “copy flash: flashbackup.tar.gz tftp: $DATE-flashbackup.tar.gz\r”
send — “copy flash: local-userdb-export tftp: $DATE-local-userdb.bin\r”
send — “exit\r”
send — “exit\r”
expect eof
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: Logo

You are commenting using your 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