Skip to content

Instantly share code, notes, and snippets.

@umarizulkifli
Forked from makenova/pritunlMigration.md
Created October 7, 2016 10:09
Show Gist options
  • Save umarizulkifli/b166c1437409a38a4815a1191dcf3b48 to your computer and use it in GitHub Desktop.
Save umarizulkifli/b166c1437409a38a4815a1191dcf3b48 to your computer and use it in GitHub Desktop.
move pritunl between servers

Migrating your pritunl install between servers

This is a small write up about how to migrate your pritunl install between servers. It's not especially detailed because I'm lazy and your migration story will most likely be different. All this can be avoided by using a remote/hosted mongo instance(compose.io, mongolab, etc.) and simply pointing your pritunl instance at that. If you want more details ask, and I'll do my best to answer and update this write-up accordingly. Also, feel free to criticize my grammar and spelling.

Stop pritunl service

sudo service pritunl stop

Make a backup of current database

mongodump

Compress backup

tar -zcvf dump.tar.gz dump

Transfer backup archive to new server

scp dump.tar.gz user@remote-server:/path/to/save/location

Install pritunl on new server

  • save the following file on your server
  • make it executable chmod u+x pritunlInstall.sh
  • run it ./pritunlInstall.sh
#!/bin/bash
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" > /etc/apt/sources.list.d/mongodb-org-3.0.list
echo "deb http://repo.pritunl.com/stable/apt trusty main" > /etc/apt/sources.list.d/pritunl.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv 7F0CEB10
apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv CF8E292A
apt-get --assume-yes update
apt-get --assume-yes upgrade
apt-get --assume-yes install pritunl mongodb-org
service pritunl start

Unarchive compressed backup

tar -zxvf dump.tar.gz

Restore backup

mongorestore dump

Allow traffic

If you block traffic with a firewall you will need to make an exception for pritunl. The pritunl admin interface is on tcp:443 and each server you setup will also have a port that you will need to setup rules for. I use ufw as my firewall so ...

sudo ufw allow https

Test it out

Go to https://SERVER_IP and accept the prompt to use the local mongodb server. Then sign-in with your pritunl username and password from the previous server. If it all checks out, delete the old server and pat yourself on the back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment