# Backup

All data for Pritunl is stored in the MongoDB database. This allows the entire system to be maintained without having to manage any complex components or configuration files. When Pritunl is installed it establishes a connection with the database using two configuration options.

The first is the MongoDB URI stored in `/etc/pritunl.conf` this URI will provide all the information needed to connect to a MongoDB database.

The second is a 32 length string in `/var/lib/pritunl/pritunl.uuid` this identifies the host in the cluster. This ID can also be viewed from the web console by holding shift and clicking the red host label. If the ID is lost it can be retrieved this way. If the ID were changed when the Pritunl service starts the host will appear as a new host in cluster, the previous host would remain until it is manually deleted from the web console.

Newer versions of Pritunl have commands to retrieve and update these values. Below are commands to backup and restore the values.

```shellscript
sudo pritunl get-mongodb
mongodb://localhost:27017/pritunl
sudo pritunl set-mongodb mongodb://localhost:27017/pritunl

sudo pritunl get-host-id
3d6bb90b269fd80073c28a352f0de983
sudo pritunl set-host-id 3d6bb90b269fd80073c28a352f0de983
```

There are other files such as `/var/lib/pritunl/setup_key` that are not important to the host configuration. The setup key is a temporary key used during the initial setup of a database when the web browser prompts to enter a MongoDB URI as shown below. This key is not used after this setup.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FI8XOf7m1dAxWkCqOFApU%2Fdatabase_setup0.png?alt=media\&token=09f0ab77-1066-49b3-98ba-4fd5924e0f4e)

### MongoDB

If the MongoDB database is run on the local server the commands below can be used to backup and restore the database. The clear message cache command should be run on a Pritunl host after a database restore.

```shellscript
mongodump --db=pritunl
tar cf pritunldb.tar dump

tar xf pritunldb.tar
mongorestore dump

sudo pritunl clear-message-cache
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pritunl.com/kb/vpn/system/backup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
