Written By: Kenton Russell
Last Moddified: 12/26/2021
Two scripts were created.
One script was created to backup all switch configurations and the other script was created to commit/push the repository to gitlab.
Disclaimer
Ideally this should be run with rsa key and not username and password. You must migrate your environment for only key authentication as Dell 6248 does now allow for both username/password and key authentication.
Windows Host Machine needed
autobackups.ps1
autocommit.ps1
switchlist.csv
Service Account (windows) : To Run Task on Win Server
Service Account (gitlab) : To push and pull from git
Task: AutoBackup
Task: AutoCommit
Set TFTP root as your git repo
The backup script was named autobackups.ps1. This script loops through the csv switchlist.csv and ssh's into the IP address using kitty.exe.
Within the script there are commands seperated by \n (a carriage return). These commands run in sequence and are as followed:
- login to switch using username and password
- Copy running-config startup-config
- Copy running-config to tftp://$Server/$TFTP_ROOT/*
- Log out of switch
The script then writes a completed log to the local repository in */Logs
If the TFTP server is not running, the script writes a Failed-Backup log to the local repository in */Logs. Additionally, the script will exit early and not go through the ssh sessions because there is not a valid TFTP root.
The commit script was named autocommit.ps1. This script navigates to the local repository. It then adds, commits, and pushes.
This local repository can be treated as the most up to date and current repository because svc-netbackups is the only account that should be changing the repository.
IF YOU NEED TO MAKE AN EDIT TO A CONFIGURATION FILE, DO IT ON THE SERVER SIDE. NOT THE GITLAB SIDE!!!
If you need to run the backup script and commit script manually, you can do so in Task Scheduler.
- Navigate to RoyalServer.ncc.lan
- Navigate to Task Scheduler
- Run AutoBackup
- Wait 6 minutes for AutoBackup to finish running (it will say script has completed, but trust me, its still working)
- Run AutoCommit
- Navigate to switchlist.csv
- Append Building, Nodename, and IP address to the csv
- RDP to your Win Server as windows service account that runs task
- Navigate to Kitty.exe
- Login to the switch using the IP inserted into the csv.
- Accept the RSA fingerprint.
- Run AutoBackup Task in Task Scheduler
- Run the AutoCommit Task in Task Scheduler
- Ensure New Backup Exists in Gitlab Repo
If you see a failure in Logs/Failed_Backups that means that the TFTP server is not running!
- Login to Windows Server
- Start SolarWindsTftp Server
- Navigate to File > Configure
- Select Start (TFTP Service)
- Run AutoBackup Task in Task Scheduler