Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Rescue and Recovery of Configuration File (Junos OS)

In the event of software failure, a rescue configuration helps to load a known working configuration. No need to remember the rollback number; if you saved a configuration, you can use it anytime when needed.

Saving and Reverting a Rescue Configuration File

Saving a Rescue Configuration File

A rescue configuration file is helpful in the event that your device’s configuration file has been misconfigured. A rescue configuration allows you to define a known working configuration or a configuration with a known state that you can roll back to at any time. This alleviates the necessity of having to remember the rollback number with the rollback command. You can restore the device to this rescue configuration to bring the device back online. If you save this file off the device, the rescue configuration can also be used to restore your device in the event of a software failure.

As of Junos OS Release 16.1, for devices running Junos OS with upgraded FreeBSD, provided you have saved a rescue configuration on the device, there is an automatic device recovery mode that goes into action should the system fail to activate the current configuration (amnesiac mode).

Note:

To determine which platforms run Junos OS with upgraded FreeBSD, see Feature Explorer, enter freebsd, and select Junos kernel upgrade to FreeBSD 10+.

You can identify that the device has recovered automatically from amnesiac mode by the following:

  • The syslog UI_DEVICE_IN_RECOVERY_MODE is generated, which indicates that there was a problem in the normal boot time commit and that Junos OS has activated the rescue configuration as the device's configuration.

  • The CLI displays the banner Device is running in Recovery Mode in both operational and configuration modes.

Starting in Junos OS Release 23.4R1 for MX Series routers, you can also prevent the device from reaching an amnesiac state post-reboot by configuring the dual-phase-bootup feature before the reboot. When a device has a scaled configuration or has a lot of constraints to be validated, upon reboot it may take more than 45 minutes to finish. This lengthy reboot time exceeds the limit set for the watchdog timer. The watchdog timer going off can cause the device to reach an amnesiac state. To avoid reaching an amnesiac state during a future reboot, configure the dual-phase-bootup statement.

If you have configured the dual-phase-bootup statement before the reboot, the device picks up the rescue configuration from the next reboot. Post-reboot, the device’s operational state is active and the device automatically loads the last-configured user configuration (juniper.conf file), thus preventing the device from reaching an amnesiac state.

To be able to commit the configuration for the dual-phase-bootup statement, you must already have created a rescue configuration (rescue.conf file). We recommend that you have a minimal rescue configuration.

This topic covers the following procedures:

Saving a Rescue Configuration

To save a current device configuration as a rescue configuration file:

  1. Edit the configuration file on the device to reflect the base configuration you wish to use.

  2. In the CLI operational mode, save this edited base configuration as the rescue configuration file:

    The rescue configuration file is automatically saved under /config directory as rescue.conf.gz.

Validating the Rescue Configuration

You can verify that the syntax of a configuration file is correct and check for commit check errors by using the test configuration filename command.

To verify if a rescue configuration file is correct:

Issue the test configuration filename command from the CLI operational mode.

If the configuration contains any syntax or commit check errors, a message is displayed to indicate the line number and column number in which the error was found. This command only accepts text files.

Copying the Configuration to a Remote Server

This task is optional but recommended.

To copy the rescue configuration to a remote server:

  1. Start the device shell.
  2. Go to the /config directory and list the rescue configuration file..
  3. FTP the configuration file to the remote host.

Rolling Back to Troubleshoot the Failed Configuration

Your rescue configuration is probably not exactly the configuration you want or need on your system. Therefore, you will want to examine the failures that occurred when you tried to activate the current configuration and make corrective actions.

To correct the failed configuration:

  1. Log in to the device through the management IP (or the console if permitted).
  2. Load the failed configuration.

    If you are doing this step right after the recovery mode, rollback 1 will be the configuration that cause the amnesiac mode.

  3. Make corrections to the configuration.
  4. Do a commit check.
  5. If there are other corrections to make, make them.
  6. Commit the configuration.

Rolling Back to the Rescue Configuration

Not all platforms run Junos OS with updated FreeBSD. Those that do not or are releases earlier than Junos OS Release 16.1, do not have the automatic recovery mode. You will need to rollback to rescue configuration manually to bring the device back to normal running mode.

To roll back to the rescue configuration:

  1. Log in to the device through the console.
  2. Issue the rollback rescue command from the configuration mode of the CLI.
  3. Commit the configuration.
  4. Fix the failed configuration. See Rolling Back to Troubleshoot the Failed Configuration.

Deleting an Existing Rescue Configuration

To delete an existing rescue configuration:

Issue the request system configuration rescue delete command:

Reverting to the Rescue Configuration

If someone inadvertently commits a configuration that denies management access to a device and the console port is not accessible, you can overwrite the invalid configuration and replace it with the rescue configuration. The rescue configuration is a previously committed, valid configuration.

To revert the switch to the rescue configuration:

  1. Enter the load override command.
  2. Commit your changes.

Copy Backup Configurations and Restore Saved Configurations

Copy Backup Configurations to the Router

To copy backup configurations to the router, follow these steps:

  1. To copy the existing configuration and any backup configurations back onto the router, use the file copy command. Place the files in the /var/tmp directory.

  2. Load and activate the desired configuration:

Restoring a Saved Configuration

To restore a saved configuration, perform the following tasks:

Copy Saved Files to the Router

To copy the saved configuration to the router:

  1. Log in to the console as root. There is no password.

    Initially, access to the router is limited to the console port after a recovery installation. Access through the management ports and interfaces is set in the configuration. For information about accessing the router through the console port, see the administration guide for your particular router.

  2. Start the CLI:

  3. Copy the configuration file on the remote server to the router’s /var/tmp directory:

Loading and Committing the Configuration File

Once the saved configuration file is copied to the router, you load and commit the file:

  1. Start the CLI configuration mode.

  2. Load the file into the current configuration. You should override the existing file.

  3. Commit the file.

  4. Exit the CLI configuration mode.

  5. Back up Junos OS.

    After you have installed the software on the router, committed the configuration, and are satisfied that the new configuration is successfully running, issue the request system snapshot command to back up the new software to the /altconfig file system. If you do not issue the request system snapshot command, the configuration on the alternate boot drive will be out of sync with the configuration on the primary boot drive.

    The request system snapshot command causes the root file system to be backed up to /altroot, and /config to be backed up to /altconfig. The root and /config file systems are on the router’s CompactFlash card, and the /altroot and /altconfig file systems are on the router’s hard disk or solid-state drive (SSD).

     

Reverting to the Default Factory Configuration by Using the request system zeroize Command

The request system zeroize command is a standard Junos OS operational mode command that removes all configuration information and resets all key values. The operation unlinks all user-created data files, including customized configuration and log files, from their directories. The device then reboots and reverts to the factory-default configuration.

To completely erase user-created data so that it is unrecoverable, use the request system zeroize media command.

CAUTION:

Before issuing request system zeroize, use the request system snapshot command to back up the files currently used to run the device to a secondary device.

To revert to the factory-default configuration by using the request system zeroize command:

  1. Remove the device from the chassis cluster.
  2. Disable the chassis cluster on the device.
  3. Reboot the device.
  4. Enter the request system zeroize command.
  5. Type yes to remove configuration and log files and revert to the factory default configuration.
  6. Complete the initial configuration of the device.