This repository code is about migrating your Nighscout data at Atlas/MongoDb (as used for deployment on Heroku) to Azure Cosmos DB for MongoDB.
The methode used here exporting/importing MongoDb data using the MongoDB client tools. These script a run from a Docker "mongo:4.4" container.
Note that the method described below assumes you have succesfully deployed your Nightcout application on Azure using the exelent tutorial How to setup the Nightscout Diabetes Management Open Source Server on Azure FOR FREE_ by Scott Hanselman (see his Youtube link) which essentially is the same as described on nightscout.github.io/vendors.
It is recommended to run this from WSL on Windows 10/11 or any linux box supporting Docker and/or mongodb.
You may choose to not use docker: it is possible to run the scripts directly on a linux host with the MongoDB client tools installed. You may need to to slightly alter the script provided fro this,
Start by editying the .env file to specify your database connection parameters.
Next start the docker container and migrate the data from Atlas to Azure:
- Start a mongodb docker container
- Export relevant MongoDb collections from the Atlas/MongoDB database by running the mongoexport tool on the container.
- Import data the data exported into the MongoDB databse on Azure running the mongoimport tool on the container
- Stop the container
Next we need to WAIT some time for the MongoDB to settle down and rebuild indexes on the newly imported data.
- WAIT for about 15 minutes
- Restart your Nighscout Azure WebApp
- Try to open/acess the NS webpage
When the site finaly start it most likely will start requesting for a default profile: IGNORE & WAIT! Be patient...
- WAIT for another 10 minutes or so.
- Try to open/access the NS webpage (it will open but most likely will have no data yet)
- Close the web page.
Be patient. The database is busy rebuilding indexes. Depending on the data size of your database this may take some time .
- WAIT for about 30 minutes.
- Open the NS web page and check the Nighscout Admin Tools until it does not show errors on reading the database.
- Use the Admin page to "trim" your database by deleting devicestatus/treatments/entries older then 180 days.
Now let the site run for some time before you start changing settings or uploading data. Have fun!
Make sure to edit the .env file!:
1. start_mongo.sh
2. export_herokudb.sh
3. restore_from_herokudump.sh
4. stop_mongo.sh
-
When setting up your Azure site following the tutorial, make sure not the define the "iob" and "cob" plugins. This can prevent the site from initial startup.
-
Do not forget to disable public access to your NS site (add setting AUTH_DEFAULT_ROLES=denied)
Nightscout Web Monitor (a.k.a. cgm-remote-monitor)
This exellent tutorial by Scott Hanselman shows how to setup your Nighscout site on Azure for Free, step by step:
How to setup the Nightscout Diabetes Management Open Source Server on Azure FOR FREE
Note that when you exactly follow de steps Scott explaines in his video blog your Nighscout deployment on Azure will be free of charge, even when the 1 year trial expires!