Brocade光纤交换机自动备份配置
一、需求描述
定期自动备份光纤交换机配置
二、需求分析
传统备份光纤交换机的配置,只收集configshow等zone配置信息,但此命令的结果输出无法直接用于配置还原操作,故采用了configupload命令进行配置备份,configupload执行输出如下:
Switch:admin> configupload
Protocol (scp, ftp, sftp, local) [ftp]: ftp
Server Name or IP Address [host]: 10.100.100.40
User Name [user]: root
Path/Filename [
Section (all|chassis|switch [all]): all
Password:
configUpload complete: All selected config parameters are uploaded
通过以上方法备份出的配置文件可直接用于配置恢复,但无法定期自动执行。
三、可执行方案
1、configupload配合参数使用
命令配合参数使用,可以执行备份任务,将此命令加入crontab中,便可实现自动定期执行备份配置的任务。
2、expect工具
expect是一个自动化交互套件,主要应用于执行命令和程序时,系统以交互形式要求输入指定字符串,实现交互通信。可在linux系统中进行安装。
此需求可以通过以下脚本予以自动执行,并将其加入crontab中,实现配置自动备份。
Vim bakswitch.sh
#!/usr/bin/expect -f
set timeout 20
spawn telnet 10.100.100.37
expect "*login*"
send "admin "
expect "Password"
send "password "
expect ">*"
send "configupload "
expect "Protocol"
send "ftp "
expect "*IP*"
send "10.100.100.40 "
expect "User*"
send "root "
expect "*Filename*"
send " "
expect "Section*"
send "all "
expect "Password"
send "root "
set time 30
expect eof