> 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/9-automatic-rollback-part-2.md).

# 9) Automatic Rollback (Part 2)

### 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 a change in the candidate configuration.

```
set system host-name XYZ
```

Commit in such a way that the change will rollback in 5 minutes automatically. Ensure you confirm the commit so that this does not happen.

### Answer

<details>

<summary>Expand to reveal</summary>

We must use `commit confirm 5` to automatically rollback in 5 minutes.

```
[edit]
admin@R1# commit confirmed 5 
commit confirmed will be automatically rolled back in 5 minutes unless confirmed
commit complete

# commit confirmed will be rolled back in 5 minutes
[edit]
admin@XYZ# 

```

\
To prevent the automatic rollback, we must `commit` again. Alternatively you can use `commit check` (explained below).

```
# commit confirmed will be rolled back in 5 minutes
[edit]
admin@XYZ# commit 
commit complete

[edit]
admin@XYZ# 
```

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

In the previous lab, we saw how the automatic rollback feature helps in case you lose connectivity to the device. However, we have not yet seen how to actually confirm the change so that this rollback does not happen.

\
To confirm the change and prevent the rollback, we simply issue another `commit` statement. However, be careful that this will actually commit any additional changes that have been made to the candidate configuration between the time you issued the `commit confirm` command and the confirmation `commit` command.&#x20;

\
For this reason, a common technique is to use `commit check` instead. This still prevents the automatic rollback, but it will not commit any pending changes at the same time.

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

[edit]
admin@R1# commit confirmed 5
commit confirmed will be automatically rolled back in 5 minutes unless confirmed
commit complete

# commit confirmed will be rolled back in 5 minutes
[edit]
admin@XYZ# commit check 
configuration check succeeds

[edit]
admin@XYZ# 
```

\
Also note that if you just use `commit` to confirm the commit, you create a fully new commit, which increments all rollback numbers by one. Therefore, to "rollback 1" you actually now need to "rollback 2." (Rollback 0 and rollback 1 are now the same thing, assuming no new changes were added between the `commit confirm` and `commit`).

\
The other benefit of using `commit check` is that it doesn't create a new commit. You can "rollback 1" as normal to rollback to the previous config.

</details>

### Further Reading

<https://www.networkcuriosity.com/junos-commit-confirmed-example/>

[https://www.reddit.com/r/Juniper/comments/1iuddvv/does\_commitconfirm\_and\_commit\_need\_to\_b](https://www.reddit.com/r/Juniper/comments/1iuddvv/does_commitconfirm_and_commit_need_to_be_done_in/)

<https://www.reddit.com/r/networking/comments/743pm2/junos_forcing_commit_confirmed/>

<https://www.youtube.com/watch?v=2tzbRUmnOVw>
