Retrieve a Previous (Rollback) Configuration Using NETCONF
A NETCONF client application can use the
<get-rollback-information> request tag to retrieve a previously
committed configuration.
Junos OS and Junos OS Evolved store a copy of the most recently committed configuration and up to 49 previous configurations, depending on the platform. When you successfully commit a configuration, the device associates that configuration with a rollback index, where the most recently committed configuration has rollback index 0. The rollback index for a committed configuration increments with each commit. When you request a previously committed configuration, you can reference the configuration by its current rollback index.
A NETCONF client application can
retrieve a previously committed (rollback) configuration from a device running Junos
OS or a device running Junos OS Evolved. To retrieve the configuration using the
rollback index, the client application executes the
<get-rollback-information> RPC with the
<rollback> element. The <rollback>
element specifies the rollback index of the previous configuration to retrieve. The
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). This
operation is equivalent to the show system rollback operational
mode command.
To request Junos XML-tagged output, which is the default, the
application either includes the <format>xml</format>
element or omits the <format>
element.
<rpc>
<get-rollback-information>
<rollback>index-number</rollback>
</get-rollback-information>
</rpc>
The NETCONF server encloses its response in
<rpc-reply>,
<rollback-information>, and
<configuration> elements. The
<ok/> tag is a side effect of the implementation and does
not affect the results.
<rpc-reply xmlns="URN" xmlns:junos="URL">
<rollback-information>
<ok/>
<configuration attributes>
<!-- tag elements for complete previous configuration -->
</configuration>
</rollback-information>
</rpc-reply>
To request formatted ASCII output, the application includes the
<format>text</format> element.
<rpc>
<get-rollback-information>
<rollback>index-number</rollback>
<format>text</format>
</get-rollback-information>
</rpc>
The NETCONF server encloses its response in
<rpc-reply>,
<rollback-information>,
<configuration-information>, and
<configuration-output> elements.
<rpc-reply xmlns="URN" xmlns:junos="URL">
<rollback-information>
<ok/>
<configuration-information>
<configuration-output>
/* previous configuration in formatted ASCII*/
</configuration-output>
</configuration-information>
</rollback-information>
</rpc-reply>
To
request JSON format, the application includes the
<format>json</format> element.
<rpc>
<get-rollback-information>
<rollback>index-number</rollback>
<format>json</format>
</get-rollback-information>
</rpc>
The
NETCONF server encloses its response in <rpc-reply>,
<rollback-information>,
<configuration-information>, and
<json-output>
elements.
<rpc-reply xmlns="URN" xmlns:junos="URL">
<rollback-information>
<ok/>
<configuration-information>
<json-output>
<!-- JSON data for the complete previous configuration -->
</json-output>
</configuration-information>
</rollback-information>
</rpc-reply>
The following example requests Junos XML-tagged output for the rollback configuration that has an index of 2. In actual output, the JUNOS-version variable has a value such as 24.4R1, which is the initial version of Junos OS Release 24.4.