Skip to main content

Reverting Configurations

Rolling Back Commits

Every time you make a change through the web UI it counts as a "commit".

Sometimes you need to revert to a pre-commit state. In our case, a change committed re-applied VPN macros that we didn't want applied. The simplest way to correct the issue was to roll back.

If you get a OS (not a "cli") prompt on the switch you can look in /config and you will see files named juniper.conf.*.gz -- these are the historical commits. Note the switch only remembers 50 or so of them. However you can look at the date/time stamps on the files, and this will give you an idea when changes were committed:

root@router:RE:0% ls -ltr j*
---x--x---  1 root  wheel    32 Jan 10 05:24 juniper.conf.md5
-rw-r-----  1 root  wheel  2068 Mar 10 12:08 juniper.conf.3.gz
-rw-r-----  1 root  wheel  2077 Mar 10 12:08 juniper.conf.2.gz
-rw-r-----  1 root  wheel  1719 Mar 10 12:10 juniper.conf.1.gz
-rw-r-----  1 root  wheel  1599 Mar 10 13:21 juniper.conf.gz

If you want to revert to a previous config, count backwards from the latest one, which should be the "current" one.

You can check the difference between the current (possibly uncommitted) configuration with the cli command:

show | compare rollback 0

Rollback 0 is always the last commit. You can go further back in time by counting backwards from 0.

Then issue the rollback on the switch: "cli", then "edit", then "rollback NUMBER", as so:

root@stack:RE:3% cli
{master:3}
root@stack> edit
Entering configuration mode

{master:3}[edit]
root@stack# rollback 4
load complete

Next you must commit the rollback configuration to current:

{master:3}[edit]
root@stack# commit
configuration check succeeds
fpc0:
commit complete
fpc1:
commit complete
fpc2:
commit complete
fpc4:

commit complete fpc5: commit complete fpc6: commit complete fpc7: commit complete fpc8: commit complete fpc9: commit complete commit complete

{master:3}[edit]
root@stack#

(I refer to this as "going all WalMart on the switches", because of the cheesy "rollback" reference.)

Abandoning Uncommitted Changes

[edit]
root@sa1-41# rollback 0
load complete

[edit]
root@sa1-41# show | compare rollback 0

[edit]
root@sa1-41#