Backing up the active running configuration on a Cisco Catalyst or Nexus switch is a fundamental task for any network administrator. Hardware failures, corrupted firmware upgrades, accidental misconfigurations, and security breaches can take an entire network offline in seconds. Having a verified, up-to-date backup of your switch configuration guarantees that a replacement device can be staged and deployed with minimal downtime.
Managing switch configurations effectively requires understanding what states your switch stores, how Cisco IOS commands handle file transfers, and how to scale backups from single ad-hoc exports to automated enterprise pipelines.
Table of Contents
Running-Config vs. Startup-Config: Frequently Asked Questions
Before initiating any backup operation, it is essential to understand which configuration state you are capturing. Cisco switches maintain two distinct configuration files within different hardware memory layers.
What is the architectural difference between running-config and startup-config?
The running-config resides in volatile Dynamic RAM (DRAM). It reflects the immediate, operational state of the switch, processing all active switching, routing, and access policies in real time. Because DRAM is volatile, any power cycle or system crash completely clears the running-config.
The startup-config resides in non-volatile RAM (NVRAM). This file contains the configuration loaded by the switch during bootup. NVRAM persists across reboots, power cuts, and software upgrades.
Why does the distinction matter when taking a backup?
If an engineer modifies a switch (such as provisioning a new VLAN or altering an access control list) but does not commit those changes to NVRAM, the modifications exist solely in the running-config. Backing up the startup-config will miss all uncommitted changes. Conversely, backing up the running-config ensures an exact copy of the live operational state, including temporary or newly applied configurations.
Should you save running-config to startup-config before backing up?
In most production workflows, yes. You should run copy running-config startup-config (or the legacy shortcut write memory) before backing up your device, provided the active configuration is tested and stable. This synchronizes DRAM with NVRAM so that both the physical device’s next reboot state and your external backup match identically.
Cisco IOS Command Reference: copy running-config
The copy running-config command is the standard Cisco IOS Privileged EXEC utility for cloning the active RAM state to internal filesystems, NVRAM, or remote network endpoints.
Command Syntax
copy running-config {destination-url | startup-config | flash:[filename] | ftp:[url] | scp:[url] | tftp:[url] | usbflash0:[filename]}
Command Mode
Privileged EXEC (#)
Parameter Specifications
| Parameter | Type | Description |
|---|---|---|
startup-config | Keyword | Copies the active RAM configuration to NVRAM, updating the boot state. |
flash:[filename] | Filesystem | Copies the active configuration directly to the onboard local Flash memory. |
usbflash0:[filename] | Filesystem | Copies the configuration to an external USB mass storage drive inserted into the switch. |
tftp:[[//server]/path] | Network URL | Transfers the configuration over UDP port 69 using Trivial File Transfer Protocol. |
ftp:[[//[user[:password]@]server]/path] | Network URL | Transfers the configuration using File Transfer Protocol over TCP port 21. |
scp:[[//[user@]server]/path] | Network URL | Encrypts and transfers the configuration over SSH (TCP port 22) using Secure Copy Protocol. |
Usage Guidelines
- Interactive Prompts: If remote IP addresses or filenames are omitted from the initial command string, Cisco IOS launches an interactive prompt asking for
Address or name of remote host []?andDestination filename []?. - Precedence: Supplying inline parameters (e.g.,
copy running-config tftp://192.168.1.100/sw1.cfg) bypasses interactive confirmation prompts, enabling non-interactive scripting. - VRF Awareness: On switches utilizing Virtual Routing and Forwarding instances (VRFs) for out-of-band management, append the management VRF to ensure proper routing table lookup:
text
copy running-config tftp: /vrf Mgmt-intf
Step-by-Step Guide: Manually Exporting Running Config via TFTP, FTP, and SCP
Depending on your security standards and network environment, you can export the running configuration using unencrypted legacy protocols (TFTP, FTP) or encrypted channels (SCP).
Prerequisites
- Network Connectivity: Confirm IP reachability from the switch to the remote server using the
pingcommand. - Access Rights: Ensure you have Privileged EXEC level access (
enablemode, privilege 15) on the switch. - Firewall Openings: Verify intermediate firewalls permit TFTP (UDP 69), FTP (TCP 20/21), or SCP (TCP 22).
Method 1: Exporting to a TFTP Server
TFTP is standard in isolated lab environments due to its lightweight implementation without authentication requirements.
- Enter Privileged EXEC mode:
text
Switch> enable
Password: *******
Switch# - Execute the copy command pointing to your TFTP server:
text
Switch# copy running-config tftp: - Respond to the interactive prompts:
text
Address or name of remote host []? 192.168.10.50
Destination filename [switch-confg]? Core-SW01-running.cfg
!!
5248 bytes copied in 0.412 secs (12737 bytes/sec)
Note: Exclamation marks (!) indicate active packet transfer. An error such as%Error opening tftp...typically denotes an unroutable IP, a closed UDP 69 port, or missing write permissions on the TFTP server.
Method 2: Exporting to an FTP Server
FTP allows basic username and password authentication, preventing unauthorized writes.
- Pre-configure FTP credentials globally (optional, but prevents cleartext CLI re-entry):
text
Switch# configure terminal
Switch(config)# ip ftp username backupuser
Switch(config)# ip ftp password MySecretPassword
Switch(config)# exit - Trigger the transfer to the FTP root or specific directory:
text
Switch# copy running-config ftp://192.168.10.50/backups/Core-SW01.cfg
Writing backups/Core-SW01.cfg !
[OK - 5248/4096 bytes]
5248 bytes copied in 0.320 secs (16400 bytes/sec)
Method 3: Exporting Securely via SCP
SCP encrypts the configuration payload over SSH, preventing network credential sniffing.
- Ensure the switch has an active SSH client configuration:
text
Switch# configure terminal
Switch(config)# ip scp server enable
Switch(config)# exit - Run the SCP transfer command specifying the remote server username:
text
Switch# copy running-config scp://netadmin@192.168.10.50/Core-SW01.cfg - Enter the SSH user password when prompted:
text
Address or name of remote host [192.168.10.50]?
Destination username [netadmin]?
Destination filename [Core-SW01.cfg]?
Password: *******
Sink: C0644 5248 Core-SW01.cfg
!
5248 bytes copied in 0.812 secs (6463 bytes/sec)
How to Configure Automated Backups on Cisco Switches Using archive
Relying on manual exports leaves configurations vulnerable to untracked human modifications. Cisco IOS includes an embedded archive subsystem designed to automate backups directly from the switch operating system. It can save timestamped configurations whenever an administrator writes to memory or on an automated schedule.
Step 1: Access Global Configuration
Switch# configure terminal
Switch(config)# archive
Step 2: Define Storage Target and Dynamic File Naming
The path parameter specifies where archives are saved. Use the system tokens $h (switch hostname) and $t (system timestamp) to avoid filename collisions.
Option A — Backup to a remote TFTP server:
Switch(config-archive)# path tftp://192.168.10.50/cisco-backups/$h-$t
Option B — Backup to local flash:
Switch(config-archive)# path flash:archive/$h-$t
Step 3: Configure Event-Driven and Periodic Triggers
- Trigger on Save: Automatically export a backup whenever
write memoryorcopy running-config startup-configis executed:
text
Switch(config-archive)# write-memory - Trigger on Schedule: Set an automated interval (specified in minutes). For example, to archive every 24 hours (1440 minutes):
text
Switch(config-archive)# time-period 1440 - Limit Local Retries: Cap the number of rotated configuration files saved on device storage to prevent exhausting flash capacity:
text
Switch(config-archive)# maximum 14
Switch(config-archive)# exit
Step 4: Verify Archive Generation
Commit a test save and inspect the archive registry:
Switch# write memory
Building configuration...
[OK]
Switch# show archive
The maximum number of archive files is 14.
There are 1 archive files currently saved.
The next archive file will be named flash:archive/Core-SW01-<timestamp>-1
Archive # Name
1 flash:archive/Core-SW01-Nov-16-03-00-00.000-0 <- Most Recent
Automation Templates: Batch Backups with Python (Netmiko) and Ansible
When managing dozens or hundreds of switches, manual commands or per-device archive configurations become difficult to maintain. Network automation scripts allow you to pull configurations across all devices simultaneously into an external repository.
1. Python + Netmiko Automation Script
The following production-ready script connects to a fleet of Cisco switches over SSH, pulls the running configuration, and writes the output to timestamped .cfg files.
import os
from datetime import datetime
from netmiko import ConnectHandler
from netmiko.exceptions import NetmikoTimeoutException, NetmikoAuthenticationException
# Device inventory list
devices = [
{
"device_type": "cisco_ios",
"host": "192.168.10.11",
"username": "admin",
"password": "SecurePassword123",
"secret": "EnableSecret123",
},
{
"device_type": "cisco_ios",
"host": "192.168.10.12",
"username": "admin",
"password": "SecurePassword123",
"secret": "EnableSecret123",
},
]
backup_dir = "switch_backups"
os.makedirs(backup_dir, exist_ok=True)
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
for device in devices:
host = device["host"]
print(f"Connecting to {host}...")
try:
net_connect = ConnectHandler(**device)
net_connect.enable()
# Disable paging to pull entire output cleanly
net_connect.send_command("terminal length 0")
running_config = net_connect.send_command("show running-config")
filename = f"{backup_dir}/{host}_{timestamp}.cfg"
with open(filename, "w") as backup_file:
backup_file.write(running_config)
print(f"[SUCCESS] Saved backup to {filename}")
net_connect.disconnect()
except (NetmikoTimeoutException, NetmikoAuthenticationException) as err:
print(f"[ERROR] Connection failed for {host}: {err}")
2. Ansible Playbook Template
If your infrastructure uses Ansible for configuration management, the cisco.ios.ios_config collection can automatically capture running configurations with built-in backup hooks.
---
- name: Batch Backup Cisco Switch Running Configurations
hosts: cisco_switches
gather_facts: no
connection: network_cli
tasks:
- name: Ensure running configuration is retrieved and backed up
cisco.ios.ios_config:
backup: yes
backup_options:
filename: "{{ inventory_hostname }}_{{ ansible_date_time.date }}.cfg"
dir_path: "./ansible_backups/"
register: backup_status
- name: Display backup file location
ansible.builtin.debug:
msg: "Backup stored at: {{ backup_status.backup_path }}"
Enterprise and Open-Source Network Configuration Management (NCM) Tools
For environments requiring role-based access, visual diff tracking, compliance auditing, and syslog-triggered backups, dedicated Network Configuration Management (NCM) platforms provide scalable solutions.
| Platform | License Model | Primary Backup Mechanism | Versioning & Git Support | Config Compliance Auditing | Best Suited For |
|---|---|---|---|---|---|
| Oxidized | Open Source (Apache 2.0) | SSH / Telnet / REST APIs via Ruby workers | Native Git integration (commits per backup change) | No (requires external diff engines) | Devops-oriented teams and automated Linux environments. |
| RANCID | Open Source (BSD-like) | Expect scripts via CVS/SVN/Git | Version controlled via local CVS/SVN/Git repositories | Basic plain-text diffs | Legacy infrastructures needing lightweight, low-overhead monitoring. |
| SolarWinds NCM | Commercial (Proprietary) | SNMP triggers, scheduled CLI polling, Syslog integration | Integrated database with GUI visual diff comparison | Comprehensive (HIPAA, PCI-DSS, DISA STIG, Cisco CIS) | Large enterprises requiring turnkey compliance and centralized monitoring. |
| ManageEngine NCM | Commercial (Proprietary) | Scheduled discovery, SSH/Telnet polling, Syslog change alerts | Built-in database versioning and rollback controls | Rule-based compliance checks and auto-remediation | Mid-to-large IT teams looking for out-of-the-box vendor agnostic auditing. |
| Unimus | Commercial (Freemium/Tiered) | Lightweight agents using SSH/Telnet | Built-in historical diff viewer with automated notifications | Basic configuration validation | Rapid multi-vendor deployments needing a streamlined, low-complexity GUI. |
Conclusion
Backing up a Cisco switch’s running configuration involves more than just executing a one-time command; it requires building a reliable, layered disaster recovery strategy.
For routine maintenance and ad-hoc changes, understanding the volatile nature of the running-config and using copy running-config over TFTP, FTP, or SCP gives you immediate operational safety. On individual production switches, deploying the Cisco IOS archive utility ensures that no configuration change made via write memory goes unrecorded. Finally, as your environment scales, adopting automation scripts using Python or Ansible—or running a centralized NCM system like Oxidized or SolarWinds—ensures your organization maintains complete version history, rapid hardware recovery capabilities, and uninterrupted compliance.











Comments