EdgeRouter - Archiving and Managing the Configuration Files
Overview
Readers will learn different ways to manage the EdgeOS configuration files using the Command Line Interface (CLI).
Table of Contents
Saving and Loading Backup Configurations
The EdgeRouter uses three configuration sets:
-
Boot/Startup Config
When the EdgeRouter reboots, it loads the boot/startup configuration (config.boot) located in the /config/ directory. -
Active Config
The active configuration including changes that have committed but not yet saved to the boot/startup configuration yet. When changes are committed, but not saved, and a reboot occurs the committed changes that have not been saved are lost. -
Working Config
Non-active configuration with changes that have not been applied (committed) yet.
Use the following commands (in CLI) to make changes to the configuration:
-
set
Adds a configuration statement to the device. -
delete
Removes a configuration statement from the device. -
commit
Applies any changes that were added with the set or delete commands. -
save
Saves the active configuration to the boot/startup configuration.
Typically, you use the save command to save the active configuration to the boot/startup configuration (config.boot). However, you can also save the active configuration to a different file or remote server.
If you wish to save the active configuration to a different file on the local device, follow the steps below:
1. Enter configuration mode.
ubnt@edgerouter:~$ configure
2. Save the configuration to a different local file.
[edit]
ubnt@edgerouter# save ?
Possible completions: <Enter> Save to system config file
<file> Save to file on local machine
[edit]
ubnt@edgerouter# save backupconfig.boot
Warning: saving configuration to non-default location '/config/backupconfig.boot
3. Verify that the backup file is saved to the config directory and optionally verify its contents.
[edit]
ubnt@edgerouter# ls -l /config/
-rw-rw---- 1 root vyattacf 2874 Apr 1 22:24 config.boot
-rw-rw-r-- 1 root vyattacf 2757 Apr 2 13:43 backupconfig.boot
[edit]
ubnt@edgerouter# cat /config/backupconfig.boot
firewall {
all-ping enable
broadcast-ping disable
<...output shortened...>
If you wish to save the active configuration to a remote device, follow the steps below:
1. Enter configuration mode.
ubnt@edgerouter:~$ configure
2. Save the configuration to a remote machine using either TFTP, SCP, FTP or SFTP.
[edit]
ubnt@edgerouter# save ?
Possible completions: scp://<user>:<passwd>@<host>/<file> Save to file on remote machine
sftp://<user>:<passwd>@<host>/<file> Save to file on remote machine
ftp://<user>:<passwd>@<host>/<file> Save to file on remote machine
tftp://<host>/<file> Save to file on remote machine
[edit]
ubnt@edgerouter# save tftp://192.168.1.10/config.boot
Warning: saving configuration to non-default location 'tftp://192.168.1.10/config.boot'...
######################################################################## 100.0%
Done
If you wish to load a backup configuration from a remote device, follow the steps below:
1. Enter configuration mode.
ubnt@edgerouter:~$ configure
2. Load the backup configuration from a local or a remote file.
[edit]
ubnt@edgerouter# load ?
Possible completions:
<Enter> Load from system config file
<file> Load from file on local machine
scp://<user>:<passwd>@<host>/<file> Load from file on remote machine
sftp://<user>:<passwd>@<host>/<file> Load from file on remote machine
ftp://<user>:<passwd>@<host>/<file> Load from file on remote machine
http://<host>/<file> Load from file on remote machine
tftp://<host>/<file> Load from file on remote machine
[edit]
ubnt@edgerouter# load backupconfig.boot
Loading configuration from '/config/backupconfig.boot'...
Load complete. Use 'commit' to make changes active.
3. Compare the differences between the backup/working configuration and the active configuration.
[edit]
ubnt@edgerouter# compare
4. Commit the changes
[edit]
ubnt@edgerouter# commit
5. Save the active configuration to the startup/boot configuration.
[edit]
ubnt@edgerouter# save
Saving configuration to '/config/config.boot'...
Commit Revisions and Archival
Instead of manually backing up and maintaining backup files, EdgeOS also supports an automatic remote backup feature. The commit-archive command allows you to automatically backup the configuration after each commit.
1. Enter configuration mode.
ubnt@edgerouter:~$ configure
2. Automatically send committed configurations to a TFTP, SCP or FTP server:
[edit]
ubnt@edgerouter# set system config-management commit-archive location ?
Possible completions:
<uri> Uniform Resource Identifier Detailed information:
"scp://<user>:<passwd>@<host>/<dir>"
"ftp://<user>:<passwd>@<host>/<dir>"
"tftp://<host>/<dir>"
[edit]
ubnt@edgerouter# set system config-management commit-archive location tftp://192.168.1.1/archive
3. Commit the changes.
[edit]
ubnt@edgerouter# commit
Archiving config... tftp://192.168.1.1/archive OK
You can also keep a specified number of commit revisions (configuration files) on the local device by using the commit‑revisions statement.
1. Enter configuration mode.
ubnt@edgerouter:~$ configure
2. Specify the amount of revisions to keep.
[edit]
ubnt@edgerouter# set system config-management commit-revisions 10
3. Commit the changes.
[edit]
ubnt@edgerouter# commit
4. Test the feature by enabling a random service.
[edit]
ubnt@edgerouter# set service telnet port 23
ubnt@edgerouter# compare
[edit service]
+telnet {
+ port 23
+}
[edit]
ubnt@edgerouter# commit
[ service telnet ]
Starting the telnet service. Check /var/log/messages.
5. Verify the commit revision list.
ubnt@edgerouter:~$ show system commit
0 2018-04-02 22:07:58 by ubnt via cli
commit
1 2018-04-02 22:07:50 by ubnt via cli
commit
2 2018-04-02 22:07:50 by root via init
commit
The following commands allow you to compare the different commit files.
-
show system commit
List all the current commit revisions -
show system commit diff <nr>
Compare the difference between this commit and the previous commit. -
show system commit file <nr>
Display the contents of this commit configuration file.
It is possible to add comments to commits to easily see which revision added which feature:
[edit]
ubnt@edgerouter# delete service telnet
[edit]
ubnt@edgerouter# commit comment removed-telnet
[edit]
ubnt@edgerouter# run show system commit
0 2018-04-02 22:18:07 by ubnt via cli
removed-telnet
1 2018-04-02 22:17:17 by ubnt via cli
commit
2 2018-04-02 22:17:08 by ubnt via cli
commit
Lastly, you can restore a previous configuration revision by using the rollback command.
[edit]
ubnt@edgerouter# rollback ?
Possible completions:
<N> Rollback to revision N (currently requires reboot)
Revisions:
0 2018-04-02 22:18:07 ubnt by cli
1 2018-04-02 22:17:17 ubnt by cli
2 2018-04-02 22:17:08 ubnt by cli
3 2018-04-02 22:07:58 ubnt by cli
4 2018-04-02 22:07:50 ubnt by cli
5 2018-04-02 22:07:50 root by init
[edit]
ubnt@edgerouter# rollback 2
Proceed with reboot? [confirm][y]
The system is going down for reboot NOW
Related Articles
Intro to Networking - How to Establish a Connection Using SSH