Retrieve the Rescue Configuration Using NETCONF
A NETCONF client application can use the
<get-rescue-information> request tag to retrieve the existing
rescue configuration on a Junos device.
A rescue configuration allows you to define a known working configuration or a configuration with a known state that you can restore at any time. You use the rescue configuration to revert to a known configuration or as a last resort if the device configuration and the backup configuration files become damaged beyond repair.
You must create a rescue configuration on the device before you can retrieve or use it. When you create a rescue configuration, the device saves the most recently committed configuration as the rescue configuration. You can create a rescue configuration using the following methods:
-
In a NETCONF session, use the
<request-save-rescue-configuration>request tag. -
In the Junos OS CLI, issue the
request system configuration rescue saveoperational mode command.
A NETCONF client application can retrieve the rescue configuration from devices
running Junos OS or devices running Junos OS Evolved. A client application requests
the rescue configuration by emitting an <rpc> element and
enclosing the Junos XML <get-rescue-information> request tag.
The operation is equivalent to the show system configuration rescue
operational mode command.
<rpc>
<get-rescue-information/>
</rpc>By default the server returns the rescue configuration in Junos XML format. To
explicitly request XML output, the application can also include the
<format>xml</format> element.
<rpc>
<get-rescue-information>
<format>xml</format>
</get-rescue-information>
</rpc>
The NETCONF server encloses its response in <rpc-reply>,
<rescue-information>, and
<configuration> tag elements. The
<ok/> tag is a side effect of the implementation and does
not affect the results.
<rpc-reply xmlns="URN" xmlns:junos="URL">
<rescue-information>
<ok/>
<configuration attributes
<!-- tag elements representing the rescue configuration -->
</configuration>
</rescue-information>
</rpc-reply>
To request the rescue configuration in formatted ASCII output, the application
includes the <format> element with the value
text.
<rpc>
<get-rescue-information>
<format>text</format>
</get-rescue-information>
</rpc>
The NETCONF server encloses its response in <rpc-reply>,
<rescue-information>,
<configuration-information>, and
<configuration-output> tag elements.
<rpc-reply xmlns="URN" xmlns:junos="URL">
<rescue-information>
<ok/>
<configuration-information>
<configuration-output>
/* formatted ASCII for the rescue configuration*/
</configuration-output>
</configuration-information>
</rescue-information>
</rpc-reply>
To request the rescue configuration in JSON format, the application includes the
<format> element with the value json.
<rpc>
<get-rescue-information>
<format>json</format>
</get-rescue-information>
</rpc>The NETCONF server encloses its response in <rpc-reply>,
<rescue-information>,
<configuration-information>, and
<json-output> elements.
<rpc-reply xmlns="URN" xmlns:junos="URL">
<rescue-information>
<ok/>
<configuration-information>
<json-output>
{
"configuration" : {
<!-- JSON data representing the rescue configuration -->
}
}
</json-output>
</configuration-information>
</rescue-information>
</rpc-reply>