Rescue and Recovery of Configuration File
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).
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.
This topic covers the following procedures:
Saving a Rescue Configuration
To save a current device configuration as a rescue configuration file:
Edit the configuration file on the device to reflect the base configuration you wish to use.
In the CLI operational mode, save this edited base configuration as the rescue configuration file:
user@host> request system configuration rescue save
The rescue configuration file is automatically saved under
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.user@host> test configuration /config/rescue.conf.gzconfiguration check succeeds
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:
- Start the device shell.user@host> start shell
- Go to the
/configdirectory and list the rescue configuration file..% cd /config% ls -lrt rescue.conf.gz-rw-r----- 1 root wheel 1483 Dec 14 10:50 rescue.conf.gz
- FTP the configuration file to the remote host.
% ftp host2
Name: username Password: password User user logged in. ftp> cd /var/tmp ftp> lcd /config ftp> bin ftp> put rescue.conf.gz local: rescue.conf.gz remote: rescue.conf.gz Transfer complete. ftp> bye Goodbye.
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:
- Log in to the device through the management IP (or the console if permitted).
- Load the failed configuration.user@host# rollback 1
If you are doing this step right after the recovery mode, rollback 1 will be the configuration that cause the amnesiac mode.
- Make corrections to the configuration.
- Do a commit check.user@host># commit check
- If there are other corrections to make, make them.
- Commit 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:
- Log in to the device through the console.
- Issue the rollback rescue command from the
configuration mode of the CLI.
user@host# rollback rescue
- Commit the configuration.
- 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: user@host> request system configuration rescue delete
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:
- Enter the load override command.user@switch# load override filename
- Commit your changes.user@switch# commit filename
Copy Backup Configurations and Restoring a Saved Configurations
Copy Backup Configurations to the Router
To copy backup configurations to the router, follow these steps:
To copy the existing configuration and any backup configurations back onto the router, use the file copy command. Place the files in the
/var/tmpdirectory.user@host> file copy var/tmp/filename
Load and activate the desired configuration:root@> configureroot@# load merge/config/filename or load replace/config/filenameroot@# commit
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:
Log in to the console as root. There is no password.
Escape character is '^]'.
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.
Start the CLI:
Copy the configuration file on the remote server to the router’s
root@host> ftp remote-server
Type set to I.
ftp> get /path/file
Loading and Committing the Configuration File
Once the saved configuration file is copied to the router, you load and commit the file:
Start the CLI configuration mode.
Entering configuration mode
Load the file into the current configuration. You should override the existing file.
load override /var/tmp/filename
Commit the file.
Exit the CLI configuration mode.
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
/altconfigfile 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
/configto be backed up to
/altconfig. The root and
/configfile systems are on the router’s CompactFlash card, and the
/altconfigfile 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 switch 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.
Before issuing request system zeroize, use the request system snapshot command to back up the files currently used to run the switch to a secondary device.
To revert to the factory-default configuration by using the request system zeroize command:
user@switch> request system zeroize
warning: System will be rebooted and may not boot without configuration
Erase all data, including configuration and log files? [yes,no] (yes)
- Type yes to remove configuration and log files and revert to the factory default configuration.
- Complete the initial configuration of the switch.