Assumptions:
1. You have a Nightscout site hosted at Heroku
2. You have used the Heroku dashboard and the config vars to note your mlab url, username and password
3. You have a linux machine or a mac pre-installed with docker and docker-compose

Getting started - backup (or dump) your database

From the command line create a directory on your machine to store your mongo backups

mkdir ~/mongo-backups
cd ~/mongo-backups

Then backup your mlab database to this directory:

mongodump -h {server}.mlab.com:19250 -d {database name} -u {username} -p {password} -o /path/to/backup/directory

Note: username maybe the same as database name

If successful, your backup directory should now contain a directory with the database name. You can rename this directory with a name containing the date so you can archive or to roll back at another time.

Install and run the Nightscout docker image

From: https://github.com/nightscout/nightscout-docker

Create and move to a new directory to download the docker image

mkdir ~/installs
cd ~/installs
git clone https://github.com/nightscout/nightscout-docker.git
cd nightscout-docker

Next, edit the docker file:

nano docker-compose.yml

Uncomment the 'ports' lines by removing the hashes

# Uncomment if you want to expose the MongoDB port directly
# If you're using the API interface (highly recommended) then you can
# safely leave this commented out
ports:
- '27017:27017'

Change the MONGODB_PASS and the password in the MONGO_CONNECTION string (don't change the db name)

##TODO: add other config vars as required under the nightscout: / environment: section

Save the docker-compose.yml file

Run docker-compose

sudo docker-compose up

Now change back to your mongo backups directory

cd ~/mongo-backups
mongorestore -h=172.17.0.3:27017 -u=admin -p={MONGODB_PASS} the_dumped_db_name/

The IP address above is what worked for me. If you have other docker images running, your IP will be different.

If those commands seemed to work, fire up your browser and navigate to:

127.0.0.1:1337

Good luck!