Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Retrieving a Previous (Rollback) Configuration Using the Junos XML Protocol

 

In a Junos XML protocol session with a device running Junos OS, a client application can request a previously committed (rollback) configuration. The client can retrieve the configuration by referencing the configuration’s rollback index or its configuration revision identifier.

How to Retrieve a Configuration Using the Rollback Number

In a Junos XML protocol session with a device running Junos OS, to request a previously committed (rollback) configuration, a client application executes the <get-rollback-information> RPC with the <rollback> element. This operation is equivalent to the show system rollback operational mode command. The <rollback> element specifies the rollback index of the previous configuration to display; its value can be from 0 (zero, for the most recently committed configuration) through one less than the number of stored previous configurations (maximum is 49).

To request Junos XML-tagged output, which is the default, the application either includes the <format> element with the value xml or omits the <format> element.

The Junos XML protocol server encloses its response in <rpc-reply>, <rollback-information>, and <configuration> tag elements. The <load-success/> tag is a side effect of the implementation and does not affect the results. For information about the attributes in the opening <configuration> tag, see Specifying the Source for Configuration Information Requests in a Junos XML Protocol Session.

To request formatted ASCII output, the application includes the <format> element with the value text.

The Junos XML protocol server encloses its response in <rpc-reply>, <rollback-information>, <configuration-information>, and <configuration-output> tag elements. For more information about the formatted ASCII notation used in Junos OS configuration statements, see Specifying the Output Format for Configuration Data in a Junos XML Protocol Session.

Starting in Junos OS Release 16.1, to request a previously committed (rollback) configuration in JSON format, the application includes the <format> element with the value json in the <get-rollback-information> element. Prior to Junos OS Release 16.1, JSON-formatted data is requested by including the format="json" attribute in the opening <get-rollback-information> tag.

When you use the format="json" attribute to specify the format, the Junos XML protocol server encloses its response in an <rpc-reply> element, the field name for the top-level JSON member is "rollback-information", and the emitted configuration data uses an older implementation for serialization. When you use the <format>json</format> element to request JSON-formatted data, the Junos XML protocol server encloses its response in <rpc-reply>, <rollback-information>, <configuration-information>, and <json-output> tag elements, the field name for the top-level JSON member is "configuration", and the emitted configuration data uses a newer implementation for serialization.

The following example shows how to request Junos XML-tagged output for the rollback configuration that has an index of 2. In actual output, the JUNOS-version variable is replaced by a value such as 20.4R1 for the initial version of Junos OS Release 20.4.

How to Retrieve a Configuration Using the Configuration Revision Identifier

When you successfully commit a configuration, Junos OS assigns that configuration a unique configuration revision identifier. Whereas the rollback index for a previously committed configuration increments with each commit, the configuration revision identifier remains static for the same configuration.

Starting in Junos OS Release 20.4R1, a Junos XML protocol client application can use the <get-configuration-by-revision> RPC to retrieve the configuration corresponding to a given configuration revision identifier. For example:

The server returns the requested configuration enclosed in the <configuration-revision-information> element.

By default, the <get-configuration-by-revision> RPC returns the configuration in XML format. To return the configuration as text or JSON, include the <format> element in the RPC and specify text or json.

You can determine the mapping between a configuration revision identifier and the current rollback index for a particular configuration. Remember that the configuration revision identifier for a given committed configuration is static whereas the rollback index increments with each commit.

To determine the rollback number corresponding to a specific configuration revision identifier, execute the <get-configuration-by-revision> RPC, specify the revision identifier, and include the empty <rollback-number/> tag.

The device returns the rollback index currently associated with that configuration revision identifier.

Similarly, to determine the configuration revision identifier currently associated with a specific rollback number, execute the <get-rollback-information> RPC, specify the rollback index, and include the empty <configuration-revision/> tag.

The device returns the configuration revision identifier currently associated with that rollback index.

A client application can also retrieve the mapping of configuration revision identifiers to rollback indices by viewing the device’s commit history. To view the commit history and include the configuration revision identifiers, a client application executes the <get-commit-information> RPC with the <include-configuration-revision/> child element. The server returns XML output equivalent to the show system commit include-configuration-revision operational mode command output.

Release History Table
Release
Description
Starting in Junos OS Release 16.1, to request a previously committed (rollback) configuration in JSON format, the application includes the <format> element with the value json in the <get-rollback-information> element.