> 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/22-automatic-config-backups.md).

# 22) Automatic Config Backups

### 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 configure the router to backup the config file to an FTP server, with the following parameters:

* Backups should be taken whenever a commit is done, as well as every 24 hours
* Backups should be transferred via FTP to `10.0.0.1`
  * Username `user1`
  * Password `password1`
  * Directory `/backups/juniper` on the FTP server

### Answer

<details>

<summary>Expand to reveal</summary>

```
set system archival configuration transfer-on-commit
set system archival configuration transfer-interval 1440
set system archival configuration archive-sites ftp://user1@10.0.0.1/backups/juniper password password1
```

\
Similar to user plain-text-passwords, the password will be automatically hashed:

```
[edit]
admin@R1# show | compare 
[edit system]
+   archival {
+       configuration {
+           transfer-interval 1440;
+           archive-sites {
+               "ftp://user1@10.0.0.1/backups/juniper" password "$9$f539AtORcluOds4ZkquO1IEylKM"; ## SECRET-DATA
+           }
+       }
+   }

```

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

This feature is called configuration archival, and it is fairly straightforward. We can configure the router to transfer the configuration upon a commit using `transfer-on-commit`. We can configure the router to transfer the configuration periodically using `transfer-interval <minutes>`.

\
Note that if you are using SFTP or SCP, you may need to fetch the host-key of the server using `set security ssh-known-hosts fetch-from-server <server IP>` from config mode. You don't commit after entering this command; it will immediately grab the host-key.

</details>

### Further Reading

<https://www.juniper.net/documentation/us/en/software/junos/cli/topics/task/junos-software-system-management-router-configuration-archiving.html>

<https://www.networkcuriosity.com/junos-archival-example-using-sftp/>

<https://youtu.be/SJQT4pmvRYQ?t=189>
