> For the complete documentation index, see [llms.txt](https://jncia-workbook.gitbook.io/workbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jncia-workbook.gitbook.io/workbook/junos-basics/6-rollback.md).

# 6) Rollback

### Pre-Work

If you made any changes, you can quickly revert the lab using the **load\_config\_on\_nodes.py** script.

```
python3 load_config_on_nodes.py --lab_dir three-routers --config_filename basic.addressing.cfg
```

### Lab

Connect to R1 and make two changes to the configuration, and `commit`:

```
[edit]
admin@R1# set system host-name NEW-HOSTNAME 

[edit]
admin@R1# set system name-server 1.2.3.4 

[edit]
admin@R1# commit 
commit complete

[edit]
admin@NEW-HOSTNAME# 
```

Revert the configuration back to the previous config **using only one command**.

### Answer

<details>

<summary>Expand to reveal</summary>

Use `rollback 1` to revert back to the previous config, and commit:

```
admin@NEW-HOSTNAME# rollback 1 
load complete

[edit]
admin@NEW-HOSTNAME# show | compare 
[edit system]
-  host-name NEW-HOSTNAME;
+  host-name R1;
-  name-server {
-      1.2.3.4;
-  }

[edit]
admin@NEW-HOSTNAME# commit 
commit complete

[edit]
admin@R1# 
```

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

Technically, we can manually back out the changes by issuing `delete` statements, but this would violate the requirement to only use one command. Therefore this lab is testing your knowledge of the `rollback` feature. The `rollback` feature allows us to quickly roll the configuration back to a previous version.

\
Note that `rollback 0` means "roll back to the active configuration." We saw this in the previous lab: it discards any pending changes in the candidate config file. The active config is #0. That means that `rollback 1` rolls back to the previous config, before the currently active config. `Rollback 2` would be the configuration committed before that one, etc.&#x20;

\
When we run the `commit` command, the following takes place internally within Junos:

* The candidate configuration is committed to the active configuration (as long as it passes the commit checks), and becomes config #0
* The former active config becomes rollback config #1
* Each previous rollback config file is incremented by one. (Rollback config 1 becomes rollback config 2, etc.)
* Rollback #49, if it exists, is deleted. There are up to 49 rollback configs stored on the device.

\
The current active config (0) and last three rollback configs (1-3) are stored in `/config`. The remaining rollback configs are stored in `/var/db/config`.

</details>

### Further Reading

<https://www.juniper.net/documentation/us/en/software/junos/cli-reference/topics/ref/command/rollback.html>

<https://community.juniper.net/discussion/help-me-to-understand-show-configuration-rollback-1>
