网络设备(思科,华为交换机、路由器)自动备份配置脚本

网友投稿 644 2022-10-18


网络设备(思科,华为交换机、路由器)自动备份配置脚本

#! /bin/bash tftp_server=10.10.10.10 #tftp-server 服务器,用于存储备份文件 tftp_dir=/var/lib/tftpboot #根目录 back_dir=`date +"%Y%m%d"` #以时间名称备份 mkdir /var/lib/tftpboot/$back_dir echo "tftp_server_ip 10.10.10 , backup_dir /var/lib/tftpboot/" >> $PWD/result echo "#### $back_dir huawei-sw backup begin ####" >> $PWD/result for ip in `cat $PWD/huawei.list` #华为的list do ping -c 2 $ip &>2 >/dev/null /usr/bin/expect <<-EOF #调用expect set timeout 5 spawn telnet $ip expect "*Username:" send "admin\r" expect "*Password:" send "* * * * * \r" expect "*>" send "tftp $tftp_server put vrpcfg.zip $ip.zip\r" set timeout 10 expect " *second(s)." send "quit\r" EOF sleep 1s echo "$ip" >> $PWD/result done mv /var/lib/tftpboot/*.zip /var/lib/tftpboot/$back_dir #t移动 echo "#### $back_dir huawei-sw backup end ####" >> $PWD/result echo "#### $back_dir cisco-sw backup begin ####" >> $PWD/result for cip in `cat $PWD/cisco.list` #思科list do ping -c 2 $cip &>2 >/dev/null /usr/bin/expect <<-EOF set timeout 5 spawn telnet $cip expect "*Username:" send "admin\r" expect "*Password:" send "xxxxxxx\r" expect "*>" send "en\r" expect "*Password:" send "xxxxxxxx\r" send "copy startup-config tftp:\r" send "$tftp_server\r" send "$cip\r" set timeout 10 send "exit\r" expect EOF EOF echo "$cip" >> $PWD/result done mv /var/lib/tftpboot/10.* /var/lib/tftpboot/$back_dir echo "#### $back_dir cisco-sw backup end ####" >> $PWD/result tail -42 result | mailx -v -s "xxxxx-idc sw backup ended | from maboai mail" xxxxxx@163.com,xxxxxx@163.com # 备份完后发送邮件


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:spring boot使用@Async异步注解的实现原理+源码
下一篇:Backup Exec 16中配置Oracle备份
相关文章

 发表评论

暂时没有评论,来抢沙发吧~