Backup
Backing up Pritunl
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.
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.
MongoDB
If the MongoDB database is run on the local server the commands below can be used to backup and restore the database.
mongodump --db=pritunl
tar cf pritunldb.tar dump
tar xf pritunldb.tar
mongorestore dump
Updated almost 3 years ago