[PR #3890] [management] Add postgres support for activity event store #3980

Open
opened 2025-11-20 08:07:28 -05:00 by saavagebueno · 0 comments
Owner

Original Pull Request: https://github.com/netbirdio/netbird/pull/3890

State: closed
Merged: Yes


Describe your changes

Adds postgres as an optional storage engine for activity events while keeping sqlite as the default. To use postgres, set the environment variable NB_ACTIVITY_EVENT_STORE_ENGINE=postgres and provide a connection string via NB_ACTIVITY_EVENT_POSTGRES_DSN.

Migrating existing events to Postgres

  1. Back up the current sqlite store
mkdir backup
docker compose cp -a management:/var/lib/netbird/. backup/
  1. Load the data into Postgres
pgloader --type sqlite backup/events.db "postgresql://<PG_USER>:<PG_PASSWORD>@<PG_HOST>:<PG_PORT>/<PG_DB_NAME>"

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

**Original Pull Request:** https://github.com/netbirdio/netbird/pull/3890 **State:** closed **Merged:** Yes --- ## Describe your changes Adds postgres as an optional storage engine for activity events while keeping sqlite as the default. To use postgres, set the environment variable `NB_ACTIVITY_EVENT_STORE_ENGINE=postgres` and provide a connection string via `NB_ACTIVITY_EVENT_POSTGRES_DSN`. Migrating existing events to Postgres 1. Back up the current sqlite store ```sh mkdir backup docker compose cp -a management:/var/lib/netbird/. backup/ ``` 2. Load the data into Postgres ```sh pgloader --type sqlite backup/events.db "postgresql://<PG_USER>:<PG_PASSWORD>@<PG_HOST>:<PG_PORT>/<PG_DB_NAME>" ``` ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [x] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md).
saavagebueno added the pull-request label 2025-11-20 08:07:28 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#3980