How-To: Database
I know… “Database” isn't a verb. You can't write up an article “How-To Database”.. But here I am. The database is obviously a very important part of MeshCentral. This page should have section covering many of the basic tasks you may need to do in MeshCentral concerning the database.
Export the Database
There are several reasons yo may want to make an export of the MeshCentral database. One of the more common reasons is when migrating from one database engine to another; for example from the built-in NeDB to the more robust MongoDB. MeshCentral has built in commands which make this simple.
To export the database Stop the server, then start it again manually using the following command:
./node_modules/meshcentral/meshcentral --dbexport
This will export the database to a file called meshcentral.db.json
in the meshcentral-data directory. You may also specify the path to store the json file with the command below:
./node_modules/meshcentral/meshcentral --dbexport /path/to/save/export.json
Import the Database
Having an export database is nice and all, but pretty useless if you cannot import it again. <HTML> <span style=“color:red;font-size:110%;”>IMPORTANT: Importing a JSON file will completely overwrite the entire contents of whatever database it is being imported to. Start with a blank database and save yourself some headaches! </span> </HTML> Luckily importing a json file is just as simple as exporting it was. Make sure MeshCentralis not running, then start it manually with the command below:
./node_modules/meshcentral/meshcentral --dbimport
Running the command as shown will assume the file to be imported is in the mashcentral-data directory and is named meshcentral.db.json
. Just like the –dbexport
option, you can also specify the full path to the json file to be imported as shown in the command below:
./node_modules/meshcentral/meshcentral --dbexport /path/to/saved/export.json
Viewing Portions of the Database
To aid with debugging, there are also options to view specific frequently accessed information in the database. Just like withthe –dcexport
and –dbimport
options above, you can run these commands by making sure the MeshCentral server is not running, then running it manually and appending the desired option.
Option | Description |
---|---|
–showusers | Lists all users in the database |
–showmeshes | List all meshes (device groups) in the database |
–shownodes | Lists all nodes in the database |
–showevents | Lists all events in the database |
–showpower | Lists all power events in the database |
–showall | Lists all records in the database |