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

preview_player
ะŸะพะบะฐะทะฐั‚ัŒ ะพะฟะธัะฐะฝะธะต
๐—™๐—ผ๐—ฟ ๐—–๐—ผ๐—บ๐—ฝ๐—น๐—ฒ๐˜๐—ฒ ๐—ฃ๐˜†๐˜๐—ต๐—ผ๐—ป ๐—™๐—ผ๐—ฟ ๐—ก๐—ฒ๐˜๐˜„๐—ผ๐—ฟ๐—ธ ๐—˜๐—ป๐—ด๐—ถ๐—ป๐—ฒ๐—ฒ๐—ฟ๐˜€ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ:
๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—ณ๐—ผ๐—ฟ ๐—ฏ๐—ฒ๐—น๐—ผ๐˜„ ๐—จ๐—ฑ๐—ฒ๐—บ๐˜† ๐—–๐—น๐—ฎ๐˜€๐˜€: ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ ๐•๐ž๐ซ๐ฌ๐ข๐จ๐ง
๐‘ซ๐’Š๐’”๐’„๐’๐’–๐’๐’•๐’†๐’… ๐‘น๐’†๐’‡๐’†๐’“๐’“๐’‚๐’ ๐‘ณ๐’Š๐’๐’Œ:
To stay updated with my latest videos Please subscribe to my channel by clicking below
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
import time
import datetime

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')

SAVE_FILE = open("RTR_"+IP +'_'+ str(TNOW), 'w')
SAVE_FILE.write(output)
SAVE_FILE.close
print ('Finished config backup')
#CiscoConfigbackupNetmiko
#CiscoPythonBackup
#CiscoScheduleBackup
ะ ะตะบะพะผะตะฝะดะฐั†ะธะธ ะฟะพ ั‚ะตะผะต
ะšะพะผะผะตะฝั‚ะฐั€ะธะธ
ะะฒั‚ะพั€

๐—ฃ๐—น๐—ฎ๐˜†๐—น๐—ถ๐˜€๐˜: ๐—ฃ๐˜†๐˜๐—ต๐—ผ๐—ป ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ถ๐—ป๐—ด ๐—ณ๐—ผ๐—ฟ ๐—ก๐—ฒ๐˜๐˜„๐—ผ๐—ฟ๐—ธ ๐—˜๐—ป๐—ด๐—ถ๐—ป๐—ฒ๐—ฒ๐—ฟ๐˜€(๐Ÿญ๐Ÿฎ๐Ÿฌ+ ๐—ฉ๐—ถ๐—ฑ๐—ฒ๐—ผ๐˜€)
โ˜ธ๐—ฃ๐—น๐—ฒ๐—ฎ๐˜€๐—ฒ ๐—ณ๐—ผ๐—น๐—น๐—ผ๐˜„ ๐—ฏ๐—ฒ๐—น๐—ผ๐˜„ ๐—š๐—ถ๐˜๐—›๐˜‚๐—ฏ ๐—ฃ๐—ฎ๐—ด๐—ฒ ๐—ณ๐—ผ๐—ฟ ๐˜๐—ต๐—ฒ ๐—น๐—ฎ๐˜๐—ฒ๐˜€๐˜ ๐—ฐ๐—ผ๐—ฑ๐—ฒ๐˜€:
๐—ฃ๐—น๐—ฎ๐˜†๐—น๐—ถ๐˜€๐˜: ๐—–๐—ถ๐˜€๐—ฐ๐—ผ ๐—ก๐—ซ๐—”๐—ฃ๐—œ-๐—–๐—Ÿ๐—œ ๐—ฃ๐˜†๐˜๐—ต๐—ผ๐—ป ๐—”๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ถ๐—ผ๐—ป: ๐—ก๐—ฒ๐˜…๐˜‚๐˜€ ๐Ÿต๐—ธ :๐—ฃ๐—ฎ๐—ฟ๐˜€๐—ฒ ๐—ท๐˜€๐—ผ๐—ป ๐—ซ๐— ๐—Ÿ ๐—–๐—ผ๐—ป๐—ณ๐—ถ๐—ด๐˜‚๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐——๐—ฎ๐˜๐—ฎ
๐—ฃ๐—น๐—ฎ๐˜†๐—น๐—ถ๐˜€๐˜: ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐˜๐—ผ ๐—ฃ๐—ฎ๐—ฟ๐˜€๐—ฒ ๐—–๐—ถ๐˜€๐—ฐ๐—ผ ๐—–๐—ผ๐—ป๐—ณ๐—ถ๐—ด๐˜‚๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐˜‚๐˜€๐—ถ๐—ป๐—ด ๐—ฃ๐˜†๐˜๐—ต๐—ผ๐—ป ๐—ฅ๐—ฒ๐—ด๐—˜๐˜…:๐—ฟ๐—ฒ ๐—ง๐˜‚๐˜๐—ผ๐—ฟ๐—ถ๐—ฎ๐—น(๐Ÿญ๐Ÿฑ+ ๐—ฉ๐—ถ๐—ฑ๐—ฒ๐—ผ๐˜€)
๐—ฃ๐—น๐—ฎ๐˜†๐—น๐—ถ๐˜€๐˜: ๐—–๐—ถ๐˜€๐—ฐ๐—ผ ๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐—ณ๐—ฎ๐—ฐ๐—ฒ ๐—–๐—ผ๐—ป๐—ณ๐—ถ๐—ด๐˜‚๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฃ๐—ฎ๐—ฟ๐˜€๐—ถ๐—ป๐—ด ๐˜„๐—ถ๐˜๐—ต ๐— ๐˜‚๐—น๐˜๐—ถ๐˜๐—ต๐—ฟ๐—ฒ๐—ฎ๐—ฑ๐—ถ๐—ป๐—ด ๐—ฃ๐˜†๐˜๐—ต๐—ผ๐—ป ๐—ฅ๐—ฒ๐—ด๐—˜๐˜… ๐—ฆ๐—ฐ๐—ฟ๐—ถ๐—ฝ๐˜:๐—ง๐—ฎ๐—ฏ๐˜‚๐—น๐—ฎ๐˜๐—ฒ ๐—ง๐—ฎ๐—ฏ๐—น๐—ฒ ๐—ฒ๐˜…๐—ฎ๐—บ๐—ฝ๐—น๐—ฒ(๐Ÿฐ ๐—ฉ๐—ถ๐—ฑ๐—ฒ๐—ผ๐˜€)
๐—ฃ๐—น๐—ฎ๐˜†๐—น๐—ถ๐˜€๐˜: ๐—˜๐—ป๐—ฎ๐—ฏ๐—น๐—ฒ ๐—ฃ๐˜†๐˜๐—ต๐—ผ๐—ป ๐— ๐˜‚๐—น๐˜๐—ถ๐˜๐—ต๐—ฟ๐—ฒ๐—ฎ๐—ฑ๐—ถ๐—ป๐—ด ๐—ถ๐—ป ๐—–๐—ถ๐˜€๐—ฐ๐—ผ ๐—–๐—ผ๐—ป๐—ณ๐—ถ๐—ด ๐—•๐—ฎ๐—ฐ๐—ธ๐˜‚๐—ฝ ๐—ฆ๐—ฐ๐—ฟ๐—ถ๐—ฝ๐˜ ๐—ณ๐—ผ๐—ฟ ๐—ฃ๐—ฎ๐—ฟ๐—ฎ๐—น๐—น๐—ฒ๐—น ๐—ฒ๐˜…๐—ฒ๐—ฐ๐˜‚๐˜๐—ถ๐—ผ๐—ป:๐—ง๐—ต๐—ฟ๐—ฒ๐—ฎ๐—ฑ๐—ถ๐—ป๐—ด ๐—ง๐˜‚๐˜๐—ผ๐—ฟ๐—ถ๐—ฎ๐—น(๐Ÿฐ ๐—ฉ๐—ถ๐—ฑ๐—ฒ๐—ผ๐˜€)
๐—ฃ๐—น๐—ฎ๐˜†๐—น๐—ถ๐˜€๐˜: ๐—”๐—ป๐˜€๐—ถ๐—ฏ๐—น๐—ฒ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ถ๐—ป๐—ด ๐—™๐—ผ๐—ฟ ๐—ก๐—ฒ๐˜๐˜„๐—ผ๐—ฟ๐—ธ ๐—˜๐—ป๐—ด๐—ถ๐—ป๐—ฒ๐—ฒ๐—ฟ๐˜€ : ๐—ก๐—ฒ๐˜๐˜„๐—ผ๐—ฟ๐—ธ ๐—”๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐˜๐˜‚๐˜๐—ผ๐—ฟ๐—ถ๐—ฎ๐—น ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ถ๐˜€๐—ฐ๐—ผ ๐—˜๐˜…๐—ฎ๐—บ๐—ฝ๐—น๐—ฒ๐˜€(๐Ÿฏ๐Ÿฌ+ ๐—ฉ๐—ถ๐—ฑ๐—ฒ๐—ผ๐˜€)

NetworkEvolution
ะะฒั‚ะพั€

Thank you so much for your video, it helped me in my final university project.

julianonascimento
ะะฒั‚ะพั€

can you please make video of how to export status of device to csv file after execution?

MadhuSudhan-wtwv
ะะฒั‚ะพั€

I want backup of multiple show command output to be saved to a file, like "show version", "show ip BGP summary", "show clock". Is there any possibility in netmiko.

sivaprakashb
ะะฒั‚ะพั€

I wanted to save config when there any changes happen on switch or router how we can do this

pankajpatil
ะะฒั‚ะพั€

I run this script but it's throwing error while saving the config in a file:
OSError: [Errno 22] Invalid argument: 'Router_10.205.1.12020-07-10 19:03:42'..Can you help in this

titusrozario
ะะฒั‚ะพั€

how to save config with hostname of device instead of IP and time stamp ???

roger
ะะฒั‚ะพั€

You missed the Schedule Feature in this video.

wakaralam