Python learning | Part 23 |Netmiko Cisco configuration backup to file with time stamp in filename

Published: 12 April 2019
on channel: NetworkEvolution
6,830
52

𝗙𝗼𝗿 𝗖𝗼𝗺𝗽𝗹𝗲𝘁𝗲 𝗣𝘆𝘁𝗵𝗼𝗻 𝗙𝗼𝗿 𝗡𝗲𝘁𝘄𝗼𝗿𝗸 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝘀 𝗖𝗼𝘂𝗿𝘀𝗲:
𝗘𝗻𝗿𝗼𝗹𝗹 𝗳𝗼𝗿 𝗯𝗲𝗹𝗼𝘄 𝗨𝗱𝗲𝗺𝘆 𝗖𝗹𝗮𝘀𝘀: 𝟐𝟎𝟐𝟐 𝐕𝐞𝐫𝐬𝐢𝐨𝐧
𝑫𝒊𝒔𝒄𝒐𝒖𝒏𝒕𝒆𝒅 𝑹𝒆𝒇𝒆𝒓𝒓𝒂𝒍 𝑳𝒊𝒏𝒌:
https://www.udemy.com/course/python-f... Python Series Complete video Playlist URL :   • Python learning for Network Engineers...  
To stay updated with my latest videos Please subscribe to my channel by clicking below
   / @networkevolution  
This video demonstrates how to take Cisco IOS device configuration backup from the terminal using netmiko and save the file with timestamp.
from netmiko import ConnectHandler
from netmiko.ssh_exception import NetMikoTimeoutException
from paramiko.ssh_exception import SSHException
from netmiko.ssh_exception import AuthenticationException
import time
import datetime

TNOW = datetime.datetime.now().replace(microsecond=0)
IP_LIST = open('15_devices')
for IP in IP_LIST:
print ('\n '+ IP.strip() + ' \n' )
RTR = {
'ip': IP,
'username': 'admin',
'password': 'admin1',
'device_type': 'cisco_ios',
}

try:
net_connect = ConnectHandler(**RTR)
except NetMikoTimeoutException:
print ('Device not reachable.')
continue
except AuthenticationException:
print ('Authentication Failure.')
continue
except SSHException:
print ('Make sure SSH is enabled in device.')
continue

print ('Initiating cofig backup')
output = net_connect.send_command('show run')

SAVE_FILE = open("RTR_"+IP +'_'+ str(TNOW), 'w')
SAVE_FILE.write(output)
SAVE_FILE.close
print ('Finished config backup')
#CiscoConfigbackupNetmiko
#CiscoPythonBackup
#CiscoScheduleBackup


Watch video Python learning | Part 23 |Netmiko Cisco configuration backup to file with time stamp in filename online, duration hours minute second in high quality that is uploaded to the channel NetworkEvolution 12 April 2019. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 6,830 times and liked it 52 visitors.