-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SQLite store self hosted guide (#100)
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Management SQLite Store | ||
|
||
In NetBird, the management system traditionally relies on JSON file storage. | ||
Starting from version 0.24.0, we have introduced **experimental** support for SQLite. | ||
This addition aims to provide users with enhanced performance and scalability options. | ||
|
||
## SQLite Entity Relationship Diagram | ||
|
||
For a high-level overview of the SQLite schema, refer to the Entity Relationship Diagram (ERD) below: | ||
|
||
<p> | ||
<img src="/docs-static/img/selfhosted/sqlite-erd.png" alt="high-level-dia" className="imagewrapper"/> | ||
</p> | ||
|
||
## Using SQLite for Fresh Installations | ||
|
||
As of version 0.24.0, the default configuration for fresh installations is JSON file storage. | ||
However, users have the option to leverage the benefits of SQLite for new instances. | ||
To enable SQLite, update your management.json as follows: | ||
|
||
```json | ||
"StoreKind": "Sqlite", | ||
``` | ||
|
||
Alternatively, you can explicitly set the store to JSON file storage: | ||
|
||
```json | ||
"StoreKind": "JsonFile", | ||
``` | ||
|
||
## Migration from JSON Store | ||
|
||
Starting from version 0.24.0, NetBird management provides a subcommand to facilitate migration to SQLite: | ||
|
||
``` | ||
$ netbird-mgmt sqlite-migration | ||
Contains sub-commands to perform JSON file store to SQLite store migration and rollback | ||
Usage: | ||
netbird-mgmt sqlite-migration [command] | ||
Available Commands: | ||
downgrade Rollback SQLite store to JSON file store. Please make a backup of the SQLite file before running this command. | ||
upgrade Migrate JSON file store to SQLite store. Please make a backup of the JSON file before running this command. | ||
Flags: | ||
--datadir string server data directory location (default "/var/lib/netbird/") | ||
-h, --help help for sqlite-migration | ||
Global Flags: | ||
--log-file string sets Netbird log path. If console is specified the the log will be output to stdout (default "/var/log/netbird/management.log") | ||
--log-level string (default "info") | ||
Use "netbird-mgmt sqlite-migration [command] --help" for more information about a command. | ||
``` | ||
|
||
Follow these steps for migration: | ||
|
||
1. Stop NetBird management service. | ||
2. Backup your data store (`store.json` in `datadir` - default "/var/lib/netbird/"). | ||
3. Run the migration to SQLite subcommand. Example: `netbird-mgmt sqlite-migration upgrade --log-file console` | ||
4. Enable SQLite in management following [the instruction in the previous section](#using-sq-lite-for-fresh-installations). | ||
5. Run NetBird management service. | ||
|
||
|
||
## Rollback to JSON File Store | ||
|
||
To rollback to the JSON file store, follow these steps: | ||
|
||
1. Stop the NetBird management service. | ||
2. Backup your SQLite data store (`store.db` in `datadir` - default "/var/lib/netbird/"). | ||
3. Run the rollback to JSON file subcommand (Example: `netbird-mgmt sqlite-migration downgrade --log-file console`). | ||
4. Enable JSON file store in management following [the instructions for fresh installations](#using-sq-lite-for-fresh-installations). | ||
5. Restart the NetBird management service. | ||
|
||
This migration process allows users to seamlessly transition between storage options while maintaining data integrity. | ||
Ensure you perform backups before any migration or rollback operations. |