Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Returning to a Previously Committed Junos OS Configuration

This topic explains how you can return to a configuration prior to the most recently committed one, and contains the following sections:

Returning to a Configuration Prior to the One Most Recently Committed

To return to a configuration prior to the most recently committed one, include the configuration number, 0 through 49, in the rollback command. The most recently saved configuration is number 0 (which is the default configuration to which the system returns), and the oldest saved configuration is number 49.

[edit]user@host# rollback number load complete

Displaying Previous Configurations

To display previous configurations, including the rollback number, date, time, the name of the user who committed changes, and the method of commit, use the rollback ? command.

[edit]user@host# rollback ?Possible completions:<[Enter]> Execute this command<number> Numeric argument0                    2005-02-27 12:52:10 PST by abc via cli 1                    2005-02-26 14:47:42 PST by def via cli 2                    2005-02-14 21:55:45 PST by ghi via cli 3                    2005-02-10 16:11:30 PST by jkl via cli 4                    2005-02-10 16:02:35 PST by mno via cli 5                    2005-03-16 15:10:41 PST by pqr via cli 6                   2005-03-16 14:54:21 PST by stu via cli 7                    2005-03-16 14:51:38 PST by vwx via cli 8                    2005-03-16 14:43:29 PST by yzz via cli 9                    2005-03-16 14:15:37 PST by abc via cli 10                   2005-03-16 14:13:57 PST by def via cli 11                    2005-03-16 12:57:19 PST by root via other 12                    2005-03-16 10:45:23 PST by root via other 13                    2005-03-16 10:08:13 PST by root via other 14                   2005-03-16 01:20:56 PST by root via other 15                   2005-03-16 00:40:37 PST by ghi via cli 16                    2005-03-16 00:39:29 PST by jkl via cli 17                    2005-03-16 00:32:36 PST by mno via cli 18                    2005-03-16 00:31:17 PST by pqr via cli 19                    2005-03-15 19:59:00 PST by stu via cli 20                    2005-03-15 19:53:39 PST by vwx via cli 21                    2005-03-15 18:07:19 PST by yzz via cli 22                    2005-03-15 17:59:03 PST by abc via cli 23                     2005-03-15 15:05:14 PST by def via cli 24                    2005-03-15 15:04:51 PST by ghi via cli 25                   2005-03-15 15:03:42 PST by jkl via cli 26                    2005-03-15 15:01:52 PST by mno via cli 27                   2005-03-15 14:58:34 PST by pqr via cli 28                   2005-03-15 13:09:37 PST by root via other 29                    2005-03-12 11:01:20 PST by stu via cli 30                    2005-03-12 10:57:35 PST by vwx via cli 31                    2005-03-11 10:25:07 PST by yzz via cli 32                    2005-03-10 23:40:58 PST by abc via cli 33                    2005-03-10 23:40:38 PST by def via cli 34                    2005-03-10 23:14:27 PST by ghi via cli 35                    2005-03-10 23:10:16 PST by jkl via cli 36                   2005-03-10 23:01:51 PST by mno via cli 37                   2005-03-10 22:49:57 PST by pqr via cli 38                    2005-03-10 22:24:07 PST by stu via cli 39                   2005-03-10 22:20:14 PST by vwx via cli 40                    2005-03-10 22:16:56 PST by yzz via cli 41                   2005-03-10 22:16:41 PST by abc via cli 42                   2005-03-10 20:44:00 PST by def via cli 43                   2005-03-10 20:43:29 PST by ghi via cli 44                    2005-03-10 20:39:14 PST by jkl via cli 45                   2005-03-10 20:31:30 PST by root via other 46                    2005-03-10 18:57:01 PST by mno via cli 47                    2005-03-10 18:56:18 PST by pqr via cli 48                    2005-03-10 18:47:49 PST by stu via cli 49                   2005-03-10 18:47:34 PST by vw via cli |Pipe through a command[edit]

Comparing Configuration Changes with a Prior Version

In configuration mode only, when you have made changes to the configuration and want to compare the candidate configuration with a prior version, you can use the compare command to display the configuration. The compare command compares the candidate configuration with either the current committed configuration or a configuration file and displays the differences between the two configurations. To compare configurations, specify the compare command after the pipe:

[edit]user@host# show | compare (filename| rollback n)

filename is the full path to a configuration file. The file must be in the proper format: a hierarchy of statements.

n is the index into the list of previously committed configurations. The most recently saved configuration is number 0, and the oldest saved configuration is number 49. If you do not specify arguments, the candidate configuration is compared against the active configuration file (/config/juniper.conf).

The comparison output uses the following conventions:

  • Statements that are only in the candidate configuration are prefixed with a plus sign (+).
  • Statements that are only in the comparison file are prefixed with a minus sign (-).
  • Statements that are unchanged are prefixed with a single blank space ( ).

The following example shows various changes, then a comparison of the candidate configuration with the active configuration, showing only the changes made at the [edit protocols bgp] hierarchy level:

[edit]user@host# edit protocols bgp [edit protocols bgp]user@host# show
group my-group {type internal;hold-time 60;advertise-inactive;allow 1.1.1.1/32;}
group fred {type external;peer-as 33333;allow 2.2.2.2/32;}
group test-peers {type external;allow 3.3.3.3/32;}
[edit protocols bgp]user@host# set group my-group hold-time 90 [edit protocols bgp]user@host# delete group my-group advertise-inactive [edit protocols bgp]user@host# set group fred advertise-inactive [edit protocols bgp]user@host# delete group test-peers [edit protocols bgp]user@host# show | compare [edit protocols bgp group my-group]-hold-time 60;+hold-time 90;-advertise-inactive;[edit protocols bgp group fred]+advertise-inactive;[edit protocols bgp]
-group test-peers {-type external;-allow 3.3.3.3/32;}
[edit protocols bgp]user@host# show
group my-group {type internal;hold-time 90;allow 1.1.1.1/32;}
group fred {type external;advertise-inactive;peer-as 3333;allow 2.2.2.2/32;}

Creating and Returning to a Rescue Configuration

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 use the rescue configuration when you need to roll back to a known configuration or as a last resort if your router or switch configuration and the backup configuration files become damaged beyond repair.

To save the most recently committed configuration as the rescue configuration so that you can return to it at any time, issue the request system configuration rescue save command:

user@host> request system configuration rescue save

To return to the rescue configuration, use the rollback rescue configuration mode command:

[edit]user@host# rollback rescueload complete

Note: If the rescue configuration does not exist, or if the rescue configuration is not a complete, viable configuration, the rollback command fails, an error message appears, and the current configuration remains active.

To activate the rescue configuration that you have loaded, use the commit command:

[edit]user@host# rollback rescueload complete[edit]user@host# commit

To delete an existing rescue configuration, issue the request system configuration rescue delete command:

user@host> request system configuration rescue deleteuser@host>

For more information about the request system configuration rescue delete and request system configuration rescue save commands, see the Junos OS Operational Mode Commands.

Saving a Configuration to a File

Save the Junos OS configuration to a file so that you can edit it with a text editor of your choice. You can save your current configuration to an ASCII file, which saves the configuration in its current form, including any uncommitted changes. If more than one user is modifying the configuration, all changes made by all users are saved.

To save software configuration changes to an ASCII file, use the save configuration mode command:

[edit]user@host# save filename [edit]user@host#

The contents of the current level of the statement hierarchy (and below) are saved, along with the statement hierarchy containing it. This allows a section of the configuration to be saved, while fully specifying the statement hierarchy.

By default, the configuration is saved to a file in your home directory, which is on the flash drive.

When you issue this command from anywhere in the hierarchy (except the top level), a replace tag is automatically included at the beginning of the file. You can use the replace tag to control how a configuration is loaded from a file.

user@host> file show /var/home/user/myconf replace:
protocols { bgp { disable; group int { type internal;}} isis { disable; interface all { level 1 disable;} interface fxp0.0 { disable;}} ospf { traffic-engineering; reference-bandwidth 4g;...}}

Published: 2013-01-23