Backing Up the Configuration

The configuration interfaces allow you to work with parts or the whole configuration at any time. This is quite handy when it comes to backing up the system or migrating configuration from one environment to another.

Tip

Using a backup is a simple way to migrate the configuration from one environment to another.

Using the idsvr Command

The easy way to dump and restore the configuration is using the idsvr command. To do this, login to the machine where the admin node is running, and execute this command:

Listing 332 Dumping the running configuration database as XML
$ idsvr --dump-config

This will output the entire running configuration on standard out.

Using the idsh Command

You can create a backup using the idsh command as well. This can be done in operational and configuration mode. In operational mode (the default mode after starting the shell), a complete back-up can be made using a command such as this:

$ idsh
$ admin@localhost> show configuration | display xml | save /tmp/backup.xml
$ exit

Alternatively, this an done without user invention using just this command: idsh -s <<< "show configuration | display xml | save /tmp/backup.xml".

Using the Web UI

A backup can also be made using the admin UI. To do this, login in the UI and click Download from the changes menu:

../_images/download-config.png

Fig. 201 Downloading configuration from the admin UI

If there are pending changes and Download is selected from this menu, then you will be asked if the running configuration should be downloaded or if the pending configuration (which may or may not be valid) should be downloaded.

../_images/download-pending-config-modal.png

Using the RESTCONF API

The configuration is hierarchically structured under the top node in the configuration tree. In the REST interface, this is represented under:

/admin/api/restconf/data

The scheme, host, and port are the same as the admin UI (https://localhost:6749 by default).

To make a complete configuration backup, simply make a GET request on that endpoint. Basic authentication should used; the username and password are the same other management interfaces, like the UI. An example of fetching the entire non-operational data using curl and saving the result in a file is shown in Listing 333:

Listing 333 Backing up all configuration using curl
$ curl -s -u admin:Password1 "https://localhost:6749/admin/api/restconf/data?depth=unbounded&content=config" > backup.xml

It is also possible to backup subsystems by simply targeting a sub-path in the URI as shown in the following example:

$ curl -s -u "admin:Password1" \
    "https://localhost:6749/admin/api/restconf/data/profiles/profile=authentication,authentication-service?depth=unbounded&content=config" \
    > backup.xml

Restoring a Saved Configuration

Instead of replacing the running configuration with the initial factory settings, a server can be reloaded with an entire new configuration. This can be done using any of the management interfaces described above (except the Web UI). Each is described below.

Using the idsvr Command

The idsvr command supports a flag, --load-config or -l, that replaces the running configuration with that of a backup file.

$ idsvr --load-config backup.xml

Warning

Using the --load-config flag will replace the current configuration with the contents of the given file. Also, it will not update the files in $IDSVR_HOME/etc/init; instead, it will update the running configuration database.