Archive and Restore Junos OS Configurations

By Walter J. Goralski, Cathy Gadecki, Michael Bushong

When you activate a new configuration, the Junos OS software automatically keeps an archive of the previous active configuration. This automatic backup mechanism lets you return quickly to a previous configuration using the rollback command. In addition, you can copy configurations from the router to a file server. If needed, you can manually reload and restore the configuration file onto the router.

Rollback to the previous version

To return to a configuration that the Junos OS software has automatically archived, use the rollback command in configuration mode:

[edit]
user@host-name# rollback 1
load complete

This rollback command loads the previous configuration but stops short of activating it. If you need to change what’s in the configuration, you can modify it. To see what statements are in the configuration, use the configuration mode show command:

[edit]
user@host-name# show

The show command displays all the statements in a configuration one screen at a time. To see the next screen, press Enter or the spacebar.

When you’re ready to activate the configuration, use the commit command:

[edit]
user@host-name# commit
commit complete

Restore from an older version

In addition to archiving the last version of the configuration, the Junos OS software stores the last 50 active configurations. These files are on the router’s flash and hard disks, so you can restore the configuration saved in a particular file.

Use help with the rollback command to list the full archive:

[edit]
user@host-name# rollback ?
Possible completions:
 <[Enter]>         Execute this command
 0             2007-10-31 12:34:56 PST by fred via cli
 1             2007-10-31 12:30:03 PST by fred via cli
 2             2007-10-30 14:23:44 PST by fred via cli
...
48            2007-09-03 08:00:03 PST by root via cli
49            2007-09-03 07:45:21 PST by root via cli
 |             Pipe through a command

Pick the configuration by date and time and specify the number in the rollback command to load that configuration:

[edit]
user@host-name# rollback 2
load complete

Verify that the change is what you want by using the show command, and then activate it with the commit command:

[edit]
user@host-name# show
...
[edit]
user@host-name# commit
commit complete

Archive and restore to/from a server

You can manually archive configuration files by copying them to a file server on your network, following these steps:

  1. Use the Junos OS file copy operational mode command to copy the active configuration, the file juniper.conf.gz, in the router’s /config directory:

    user@host-name> file copy /config/juniper.conf.gz server1:/homes/fred/tmp
    user@server’s password:
    juniper.conf.gz              100% 2127   2.1KB/s  00:00
  2. Once the file is on the server, rename.

  3. If you need to return to that active configuration, copy it back to the router’s home directory by using the file copy command:

    user@host-name> file copy server1:/homes/fred/tmp/juniper.conf.gz-20071031
    user@server’s password:
    juniper.conf.gz-20071031         100% 2127   2.1KB/s  00:00
  4. Look at the files in your home directory to make sure the file arrived safely:

    user@host-name> file list
    juniper.conf.gz-20071031
  5. Change from operational mode to configuration mode by using the configure command, load the configuration file with the load command, and review it with the show command.

  6. Finally, activate the configuration file using the commit command:

user@host-name> configure
Entering configuration mode
[edit]
user@host-name# load juniper.conf.gz-20071031
load complete
[edit]
user@host-name# show
...
[edit]
user@host-name# commit
commit complete