My beginning attempt at networking device backups
This is my beginning attempt at making a networking device backup script. This script uses netmiko for communicating with the devices. I would love feed back.
Edit: Here is a link to the code in better formatting https://pastebin.com/V1tG8hCM
from netmiko import ConnectHandler
from datetime import datetime
from secrects import switchuser, switchpassword
import os
import json
devicelist = '/home/vetadmin/scripts/switch.json'
#skippagedisplay = "skip-page-display"
#pagedisplay = "page-display"
showrun = "show run"
#showhostname = "show run | inc hostname"
date = datetime.now().strftime("%Y%m%d")
s = 0
d = 0
#Creating the log file
logpath = ("/home/vetadmin/scripts/logging/")
if not os.path.exists(logpath):
os.makedirs(logpath)
l= open ("/home/vetadmin/scripts/logging/switchbackup.log", "a")
l.write("\n" + date + "\n")
#Opening the switch.json file that has all the switch ip information
with open(devicelist)
/r/Python
https://redd.it/q3xbsn
This is my beginning attempt at making a networking device backup script. This script uses netmiko for communicating with the devices. I would love feed back.
Edit: Here is a link to the code in better formatting https://pastebin.com/V1tG8hCM
from netmiko import ConnectHandler
from datetime import datetime
from secrects import switchuser, switchpassword
import os
import json
devicelist = '/home/vetadmin/scripts/switch.json'
#skippagedisplay = "skip-page-display"
#pagedisplay = "page-display"
showrun = "show run"
#showhostname = "show run | inc hostname"
date = datetime.now().strftime("%Y%m%d")
s = 0
d = 0
#Creating the log file
logpath = ("/home/vetadmin/scripts/logging/")
if not os.path.exists(logpath):
os.makedirs(logpath)
l= open ("/home/vetadmin/scripts/logging/switchbackup.log", "a")
l.write("\n" + date + "\n")
#Opening the switch.json file that has all the switch ip information
with open(devicelist)
/r/Python
https://redd.it/q3xbsn
Pastebin
from netmiko import ConnectHandlerfrom datetime import datetimefrom secrects - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.