Losing a switch configuration due to hardware failure, power loss, or accidental administrative changes can stall network operations and lead to hours of unplanned downtime. While every network administrator knows the manual copy running-config startup-config and copy running-config tftp: routines, relying on human diligence inevitably leads to out-of-date backups and undocumented drift.
Automating configuration backups ensures that every change is captured, versioned, and safely offloaded to remote storage without manual intervention. Whether managing a single Catalyst switch or hundreds of access layer devices across multiple campuses, modern Cisco IOS and IOS-XE platforms provide several native on-box mechanisms alongside robust external tools to automate this workflow. This guide examines the available methods, compares their capabilities, and provides practical configurations and production-ready script templates to safeguard your Cisco network infrastructure.
Table of Contents
Comparing Automated Cisco Backup Methods: Archive vs. EEM vs. Kron vs. External Tools
Before deploying an automated backup routine, you must determine whether an on-device mechanism or an external orchestration system best suits your operational scale, security posture, and infrastructure topology. Cisco IOS and IOS-XE offer three distinct native utilities—the Configuration Archive utility (archive), the Embedded Event Manager (EEM), and the legacy Command Scheduler (kron)—while centralized environments often rely on external Python scripts or dedicated Network Configuration Management (NCM) platforms.
| Method | Execution Context | Primary Trigger Types | Supported Remote Protocols | Version Tracking & Diff | Scalability | Recommended Use Case |
|---|---|---|---|---|---|---|
Cisco IOS Archive (archive) | On-box (Native) | Periodic interval (timer) or Event-driven (write memory) | TFTP, FTP, SFTP, SCP, HTTP(S), local Flash | Yes (built-in rollback and diff generation) | Per-device configuration | Standalone switches or branch offices requiring zero external dependencies. |
| Cisco EEM (Embedded Event Manager) | On-box (Native) | Granular CLI commands, Syslog patterns, SNMP traps, Cron timers | Any CLI-supported transfer (SCP, SFTP, TFTP, FTP) | No (relies on destination file naming) | Per-device configuration | Environments needing custom triggers (e.g., specific user saves, config session exits) or complex post-save actions. |
Cisco Kron (kron) | On-box (Native) | Scheduled time / Recurring calendar intervals | Indirectly via scheduled interactive CLI commands | No | Per-device configuration | Deprecated legacy IOS environments lacking full EEM support. Not recommended for modern deployments. |
| Python Automation (Netmiko / Nornir) | Off-box (External server / runner) | Cron jobs, CI/CD pipelines, or ad-hoc orchestration | SSH/SCP directly through management sessions | External (Git repositories or filesystem) | High (hundreds of devices per script) | Engineering teams seeking lightweight, customizable multi-device automation without heavy software suites. |
| Centralized NCM (Oxidized / RANCID) | Off-box (Dedicated server) | Scheduled polling, Syslog change hooks, REST API triggers | SSH, Telnet, RESTCONF | Full Git-backed revision history and web UI diffs | Enterprise (thousands of multi-vendor devices) | Production enterprise networks requiring centralized auditing, configuration compliance, and change alerts. |
For most organizations, the decision comes down to scope: native tools like archive and EEM run directly on the switch hardware without requiring management servers, making them ideal for distributed edge networks. Conversely, external scripts and NCM systems pull configurations across the entire fleet simultaneously, providing centralized Git versioning and automated change tracking.
Step-by-Step Guide: Configuring Cisco IOS Archive to Automatically Backup to TFTP/FTP
The native Cisco IOS archive feature provides the cleanest on-box solution for automated configuration management. It can generate timestamped copies on a recurring schedule and immediately whenever an administrator saves changes to NVRAM.
Step 1: Verify Remote Server Connectivity
Before configuring the switch, confirm that the switch can communicate with your remote storage server (TFTP, FTP, or SFTP) across the management plane or default VRF.
Switch# ping 192.168.10.50
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.10.50, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/3 ms
Step 2: Enter Configuration Archive Mode
Enter global configuration mode and invoke the archive sub-configuration context:
Switch# configure terminal
Switch(config)# archive
Switch(config-archive)#
Step 3: Define the Destination Path and Filename Template
Specify the remote server URL using the path command. Cisco IOS supports variable expansion within the path string:
* $h: Automatically substitutes the switch hostname.
* $t: Appends a date and time stamp based on the switch’s system clock.
For a TFTP server:
Switch(config-archive)# path tftp://192.168.10.50/backups/$h-
For an authenticated FTP server:
Switch(config-archive)# path ftp://backupuser:SecretPassword123@192.168.10.50/backups/$h-
(Note: Terminating the path with a hyphen separates the hostname from the sequence number or timestamp automatically assigned by the operating system).
Step 4: Schedule Periodic Automated Exports
Use the time-period parameter to configure a recurring background export interval, measured in minutes. For example, to initiate an automated backup once every 24 hours (1,440 minutes):
Switch(config-archive)# time-period 1440
Step 5: Enable Event-Driven Backups on Save
To guarantee that modifications are backed up immediately rather than waiting for the next daily interval, instruct the switch to trigger an export whenever write memory or copy running-config startup-config is executed:
Switch(config-archive)# write-memory
Step 6: Set Archive Limits and Commit Configuration
Define the maximum number of archive files tracked in the local index (between 1 and 14), then exit and save the configuration:
Switch(config-archive)# maximum 14
Switch(config-archive)# exit
Switch(config)# exit
Switch# write memory
Step 7: Verify Configuration Archiving
Because write-memory was enabled, saving the configuration in Step 6 triggers an immediate transfer. Confirm the archive status and review generated file records using show archive:
Switch# show archive
The maximum archive configurations allowed is 14.
There are currently 1 archive configurations saved.
The next archive file will be named tftp://192.168.10.50/backups/Switch-<timestamp>-1
Archive # Name
1 tftp://192.168.10.50/backups/Switch-Nov-16-03:10:12.102-0 <- Most Recent
2
3
Cisco IOS Archive Command Reference: Syntax, Variables, and Protocols
For precise implementation and command validation across various Cisco IOS and IOS-XE releases, reference the official syntax and operational parameters outlined below.
Command Syntax
archive
path url
[ time-period minutes ]
[ write-memory ]
[ maximum number ]
[ rollback-retry time ]
Parameter Descriptions
path url: Specifies the target destination URL prefix for archived configurations. Supports both remote network sockets and local flash partitions.time-period minutes: Configures the periodicity of the automated backup generation.- Range:
1to525600minutes (up to 1 year). - Default: Disabled (no periodic backups).
write-memory: Enables automatic generation and export of an archive file whenever the running configuration is saved to NVRAM viawrite memoryorcopy running-config startup-config.- Default: Disabled.
maximum number: Sets the upper bound of version files cataloged in the local tracking index. When exceeded, the oldest record in the index is unlinked.- Range:
1to14. - Default:
10.
Supported Protocol Schemes and URL Formats
| Protocol / Target | URL Syntax Example | Notes |
|---|---|---|
| TFTP | tftp://192.168.1.100/configs/$h- | Unauthenticated, cleartext. Requires pre-configured write permissions on the target directory. |
| FTP | ftp://user:password@192.168.1.100/dir/$h- | Authenticated, cleartext. URL-encode special characters in passwords. |
| SFTP | sftp://user:password@192.168.1.100/dir/$h- | Encrypted transport over SSH. Password strings are limited to 16 characters on some legacy platforms. |
| SCP | scp://user:password@192.168.1.100/$h- | Secure Copy Protocol. Uses default SSH user shell root directory. |
| HTTP / HTTPS | http://192.168.1.100/upload/$h- | REST or WebDAV-compatible remote ingest targets. |
| Local Flash | flash:/backup-configs/$h- | On-device NVRAM/Flash storage for isolated rollback without network connectivity. |
Dynamic Replacement Variables
When declaring the path string, the following system variables are evaluated dynamically at export runtime:
* $h: The system hostname (equivalent to the output of show running-config | include hostname).
* $t: System date and time formatted as MMM-DD-HH:MM:SS.mil. NTP synchronization is required for deterministic ordering.
Diagnostic and Verification Commands
show archive: Displays current archive settings, maximum threshold, next expected filename, and recent export logs.show archive config differences [file-url-1] [file-url-2]: Performs an on-device contextual diff comparing two saved configurations or comparing an archive file against the currentrunning-config.
Event-Driven Backups: Cisco EEM Script Template for Write-Memory Triggers
While the archive command satisfies standard export requirements, Cisco Embedded Event Manager (EEM) offers granular control. EEM applets allow you to intercept specific CLI execution patterns, suppress console warnings, inject custom syslog notifications, or authenticate against secure transfer targets (like SCP) using service-level credentials.
The following production template intercepts any configuration save action (write memory, wr, or copy running-config startup-config) and pushes an encrypted copy of the running configuration to a designated SCP server.
! Enable non-interactive CLI file transfers by disabling interactive prompts
file prompt quiet
!
event manager applet AUTO_BACKUP_ON_SAVE authorization bypass
description "Exports running configuration to SCP repository upon save"
event cli pattern "^(write memory|wr|copy run.* start.*)" sync no skip no
action 1.0 set server_ip "192.168.10.50"
action 1.1 set scp_user "backup_svc"
action 1.2 set scp_pass "Sup3rS3cur3P@ss!"
action 1.3 set target_dir "/var/backups/cisco"
!
! Format dynamic timestamp using switch system clock
action 2.0 cli command "enable"
action 2.1 cli command "show clock"
action 2.2 regex "([0-9]{2}:[0-9]{2}:[0-9]{2})" "$_cli_result" time_stamp
!
! Construct destination URL and copy file
action 3.0 set target_url "scp://$scp_user:$scp_pass@$server_ip$target_dir/$_info_routername-$time_stamp.cfg"
action 3.1 cli command "copy running-config $target_url"
!
! Log operational result to local and remote syslog
action 4.0 syslog priority informational msg "EEM: Configuration backed up successfully to $server_ip after administrative save."
!
end
Configuration Variables to Adjust
server_ip: The IPv4 or IPv6 address of your central backup server.scp_user/scp_pass: The service account credentials configured on the SSH/SCP server.target_dir: The destination directory path on the remote system.event cli pattern: RegEx matching the CLI commands that should trigger the backup. Settingskip noensures the switch saves locally to NVRAM as normal before executing the background export.
Multi-Switch Automation: Production Python (Netmiko) Backup Script
On-box automation requires configuring and maintaining scripts across every switch individually. For enterprise environments managing dozens or hundreds of devices, an off-box automation runner using Python and the Netmiko multi-vendor SSH library centralizes execution, inventory tracking, and credential management.
The script below connects concurrently to an inventory of Cisco switches, issues show running-config, strips dynamic terminal paging artifacts, and saves each configuration to a local timestamped directory.
#!/usr/bin/env python3
"""
Automated Cisco Switch Configuration Backup Script
Uses Netmiko to pull running-config across multi-device inventory.
"""
import os
from datetime import datetime
from concurrent.futures import ThreadPoolExecutor
from netmiko import ConnectHandler
from netmiko.exceptions import (
NetmikoTimeoutException,
NetmikoAuthenticationException,
)
# Output directory for configuration files
BACKUP_DIR = "./switch_backups"
TIMESTAMP = datetime.now().strftime("%Y%m%d_%H%M%S")
# Device inventory: In production, load from YAML, JSON, or NetBox/CMDB
SWITCH_INVENTORY = [
{
"device_type": "cisco_ios",
"host": "192.168.10.11",
"username": "admin",
"password": "SwitchPassword123",
"secret": "EnableSecret123",
},
{
"device_type": "cisco_ios",
"host": "192.168.10.12",
"username": "admin",
"password": "SwitchPassword123",
"secret": "EnableSecret123",
},
]
def backup_device(device: dict) -> None:
"""Connects to a single device, retrieves running-config, and writes to disk."""
host = device["host"]
try:
print(f"[*] Connecting to {host}...")
with ConnectHandler(**device) as net_connect:
# Escalate privileges if required
if device.get("secret"):
net_connect.enable()
# Retrieve switch hostname to label the backup file
prompt = net_connect.find_prompt()
hostname = prompt.replace("#", "").replace(">", "").strip()
# Execute show running-config without CLI line paging
net_connect.send_command("terminal length 0")
config_data = net_connect.send_command("show running-config")
# Write data to timestamped configuration file
filename = f"{hostname}_{host}_{TIMESTAMP}.cfg"
filepath = os.path.join(BACKUP_DIR, filename)
with open(filepath, "w", encoding="utf-8") as file:
file.write(config_data)
print(f"[+] Successfully backed up {hostname} ({host}) -> {filepath}")
except NetmikoAuthenticationException:
print(f"[!] Authentication failed for device: {host}")
except NetmikoTimeoutException:
print(f"[!] Connection timed out for device: {host}")
except Exception as exc:
print(f"[!] Unexpected error backing up {host}: {str(exc)}")
def main() -> None:
"""Initializes environment and runs multithreaded backup jobs."""
if not os.path.exists(BACKUP_DIR):
os.makedirs(BACKUP_DIR)
# Concurrently execute backups across devices (up to 5 threads)
with ThreadPoolExecutor(max_workers=5) as executor:
executor.map(backup_device, SWITCH_INVENTORY)
if __name__ == "__main__":
main()
Scheduling with Linux Cron
To automate this Python script across your infrastructure, schedule it as a recurring background cron task on your management server:
# Open crontab editor
crontab -e
# Run the backup script daily at 02:00 AM
0 2 * * * /usr/bin/python3 /opt/network-automation/backup_switches.py >> /var/log/switch_backups.log 2>&1
Dedicated Network Configuration Management (NCM) Platforms
Custom Python scripts provide flexibility, but enterprise environments with strict regulatory compliance, multi-vendor estates, and large engineering teams benefit from dedicated Network Configuration Management (NCM) platforms. These tools automate data collection, track configuration drift through Git integration, and provide intuitive change-auditing interfaces.
1. Oxidized
- License: Open Source (Ruby)
- Best For: Modern, lightweight, Git-integrated network change tracking.
- Key Capabilities:
- Designed specifically as a modern replacement for RANCID.
- Direct integration with Git repositories, creating a commit for every detected configuration difference.
- Native REST API and Web UI to view differences, node lists, and backup statuses.
- Out-of-the-box support for hundreds of network operating systems (Cisco IOS, IOS-XE, NX-OS, Junos, Arista EOS).
- Easily hooks into Network Source of Truth platforms like NetBox.
2. RANCID (Really Awesome New Cisco Config Differ)
- License: Open Source (Perl/Expect)
- Best For: Legacy infrastructure and minimal headless environments.
- Key Capabilities:
- The historical standard for automated network backups.
- Monitors device configurations and checks them into version control systems (CVS, Subversion, or Git).
- Highly stable with very low resource utilization.
- Drawbacks: Steep configuration curve, relies on older Expect scripts, and lacks an official modern graphical user interface.
3. Unimus
- License: Commercial (Free tier available for up to 5 devices)
- Best For: Fast, low-friction deployment without specialized Linux administration.
- Key Capabilities:
- Complete web-based turnkey deployment with zero scripting required.
- Automatic change notifications via email, Slack, or Webhooks.
- Built-in configuration diffing, search, and bulk configuration push capabilities.
- Includes automated discovery and out-of-the-box credential rotation.
4. SolarWinds Network Configuration Manager (NCM)
- License: Commercial Enterprise
- Best For: Large-scale enterprise compliance auditing and policy enforcement.
- Key Capabilities:
- Comprehensive policy validation (e.g., checking configs for DISA STIG, HIPAA, or PCI-DSS adherence).
- Automated vulnerability scanning that maps Cisco IOS versions and configs against published CVEs.
- Role-based access control (RBAC) with approval workflows for network changes and multi-device automated remediation.
5. ManageEngine Network Configuration Manager
- License: Commercial Enterprise
- Best For: ITIL-aligned operations requiring configuration change tracking and ticketing integration.
- Key Capabilities:
- Real-time configuration change tracking via incoming switch syslog messages.
- Rollback engine allowing operators to push previous working configurations directly from the console.
- Out-of-the-box compliance reporting and deep integration with ServiceDesk Plus.
Conclusion
Automating Cisco switch backups removes human error from disaster recovery planning and ensures that an unexpected hardware failure or misconfiguration does not disrupt operations. For isolated environments or fast zero-infrastructure setups, the native Cisco IOS archive command provides the cleanest scheduled and save-triggered baseline. When you require custom transfer options or specialized syslog validation, on-box EEM scripts deliver complete programmatic control.
As your network scales, transition from on-box utilities to centralized solutions. Lightweight Python scripts using Netmiko offer straightforward, pipeline-ready backups for smaller teams, while Git-backed platforms like Oxidized or enterprise NCM suites supply continuous drift detection, compliance auditing, and fleet-wide visibility. Combining the on-box archive or EEM feature for immediate save recovery with a nightly external NCM pull establishes a reliable, multi-tiered backup framework for your infrastructure.











Comments