Showing posts with label backup. Show all posts
Showing posts with label backup. Show all posts

Friday, 19 April 2019

Cisco switch configuration backup using PowerShell

Note: This blog has moved! New location vineethac.blogspot.com


In this article, I will briefly explain how to back up the running configuration of Cisco switches to a TFTP server location using PowerShell.

Prerequisites:
  • A TFTP server should be configured and running.
  • PowerShell module Posh-SSH should be installed on the node from which the script is running.

Workflow:
  1. Collect credentials to SSH into the switch
    $creds = Get-Credential
  2. Create a new SSH session to the first switch in the list
    $sw_ssh = New-SshSession -ComputerName <Management IP of Cisco switch> -Credential $creds -Force -ConnectionTimeout 300
  3. Invoke the command to backup running config to TFTP server over the SSH session
    $cmd_backup = "copy running-config tftp://<IP of TFTP server>/config_backup.txt vrf management"
    Invoke-sshcommand -Command $cmd_backup -SSHSession $sw_ssh

You can schedule this PS script using a task scheduler so that the running configuration of switches can be backed up automatically on a daily basis or as per requirements. Hope this was useful. Cheers!

Related article:
Dell EMC switch configuration backup using PowerShell

Sunday, 29 July 2018

Switch configuration backup using PowerShell

In this article I will briefly explain about how to backup running configuration of your Dell switches to a TFTP server location using PowerShell.

Prerequisites:

  • A TFTP server should be configured and running
Workflow:
  1. Get a list of IP address of switches that needs to be backed up
    list = Get-Content .\switch_list.txt
  2. Collect credentials to SSH into the switch
    $creds = Get-Credential
  3. Create a new SSH session to the first switch in the list
    $sw_ssh = New-SshSession -ComputerName 192.168.10.2 -Credential $creds -Force -ConnectionTimeout 300
  4. Invoke the command to backup running config to TFTP server over the SSH session
    $filename =(Get-Date).tostring("dd-MM-yyyy-hh-mm-ss")
    $cmd_backup = "copy running-config tftp://192.168.11.33/sw01/$filename.txt"
    Invoke-sshcommand -Command $cmd_backup -SSHSession $sw_ssh
  5. Repeat step 3 and 4 for all the switches in the list
Project reference:

Note:
You can schedule this PS script using a task scheduler, so that the running configuration of switches can be backed up automatically on a daily basis or as per requirements.

Hope this was useful. Cheers!