Table of Contents
Introduction
SONiC stores its persistent configuration in the file:
/etc/sonic/config_db.json
This file contains interface settings, VLANs, routing configuration, and most system parameters.
Backing up this file allows you to restore the switch configuration in case of hardware failure, misconfiguration, or device replacement.
This guide explains how to safely back up and restore SONiC configuration.
Prerequisites
- SSH or console access to the SONiC switch
- SSH/SFTP access to a remote backup server
- User account with read/write permissions on the backup server
- Basic Linux CLI knowledge
Step-By-Step Guide
Make Backup
STEP 1: Ensure the running configuration is written to disk:
sudo config save -yExample:
STEP 2: Verify configuration file exists
ls -l /etc/sonic/config_db.jsonExample:
STEP 3: Create a local backup copy
cp /etc/sonic/config_db.json config-backup_db.jsonSTEP 4: Transfer backup to remote server
scp config-backup_db.json stordis@192.168.1.200:/SONIC/BackupExample:
If you haven't previously connected to the remote host via SSH, the following message will be displayed.
Check the fingerprint on the remote host and confirm the connection by entering "yes."
Restore Backup
Important: Restoring configuration replaces the entire current setup.
STEP 1: Copy backup file to the switch
sudo scp stordis@192.168.1.200:/SONIC/Backup/config-backup_db.json . Verify the file:
ls -l config-backup_db.json
STEP 2: Restore configuration from backup
sudo cp config-backup_db.json /etc/sonic/config_db.json
STEP 3: Reload the configuration
sudo config reload -yThis applies the restored configuration.
STEP 4: Verify Configuration After Restore
After reload, verify the system state:
show runningconfiguration all
show interfaces status
show ip route
show version
Important Notes
Backups should match the same SONiC version whenever possible.
Always keep multiple backup versions.
Test restore procedures in a lab before applying in production.
-
Automating backups via scripts or Ansible is recommended for large deployments.
Documentation
GitHub - sonic-net/SONiC: Landing page for Software for Open Networking in the Cloud (SONiC)
Congratulations!
You have successfully backed up and restored the configuration of your SONiC switch!
Maintaining regular backups is crucial for:
- Accidental misconfigurations
- Firmware upgrades
- Hardware replacement
- Disaster recovery planning
If you have any questions related to this article, feel free to reach out to our technical support team.
Happy Networking!
Useful links
If you want to explore more topics, be sure to check out our other guides, including:
How to install and deploy SONiC on network switches?
How can I set up a console connection to Edgecore Open Networking switch?
How to add user and change the password in SONiC – STORDIS Support Portal
Where to download the SONiC Virtual Switch (VS) community pre-built image?
For more free resources, visit:
https://stordis.com/free-resources/
Still have questions? You can find more answers in our full FAQ - just follow the link below.
Comments 0
Comments
Please sign in to leave a comment.