配置檔備份是網管生存底線。Cisco 提供 copy 指令在 RAM (Running-config)、NVRAM (Startup-config)、TFTP/SCP/FTP 伺服器、Flash 之間互傳。本文詳細說明三大備份場景、自動化排程、加密傳輸與災難恢復演練流程。
| 指令 | 方向 | 用途 |
|---|---|---|
copy running-config startup-config | RAM → NVRAM | **存檔**,下次開機生效 (等同 write memory) |
copy running-config tftp | RAM → TFTP Server | **異地備份**,防裝置損壞/遺失配置 |
copy tftp running-config | TFTP → RAM | **還原配置** (合併模式,不覆蓋未提及項目) |
Router# copy running-config tftp
Address or name of remote host []? 192.168.100.50
Destination filename [router-confg]? R1_20240515.cfg
!!
624 bytes copied in 0.05 secs
Router#
Router# copy tftp running-config
Address or name of remote host []? 192.168.100.50
Source filename []? R1_20240515.cfg
Destination filename [running-config]?
Accessing tftp://192.168.100.50/R1_20240515.cfg...
Loading R1_20240515.cfg from 192.168.100.50 (via GigabitEthernet0/0): !
[OK - 624 bytes]
624 bytes copied in 0.09 secs
Router#
! 1. 啟用 SSH/SCP Server
ip ssh version 2
ip scp server enable
aaa new-model
aaa authentication login default local
username scpuser privilege 15 secret ScpPass2024
! 2. 從路由器推送至 SCP Server (Linux)
Router# copy running-config scp://scpuser:ScpPass2024@192.168.100.50/backups/R1_$(date +%F).cfg
! 3. 從 SCP Server 拉回
Router# copy scp://scpuser:ScpPass2024@192.168.100.50/backups/R1_20240515.cfg running-config
! 每日 02:00 備份 running-config 至 TFTP
kron policy-list DAILY_BACKUP
cli copy running-config tftp://192.168.100.50/\$h_$t.cfg
!
kron occurrence DAILY at 02:00 recurring
policy-list DAILY_BACKUP
copy tftp running-config 載入備份配置。copy running-config startup-config 存檔。reload 重啟驗證啟動正常、介面 Up、鄰居建立、業務通暢。ip tftp source-interface Loopback0、檢查 ACL。copy tftp running-config 為合併非覆蓋,殘留舊配置。→ 先 erase startup-config → reload → 再還原,或使用 configure replace (IOS 12.3+)。