Skip to content

backups: the default backup leaves out the NBXplorer database that holds BTCPay hot wallet keys #146

Closed

Description

@ostermayer

modules/backups.nix includes the NBXplorer database only when with-bulk-data is set:

services.backups.postgresqlDatabases = mkIf config.services.btcpayserver.enable (
  [ "btcpaydb" ] ++ optional cfg.with-bulk-data "nbxplorer"
);

with-bulk-data defaults to false and its description says "Bitcoin blockchain and other bulk data", so an operator who keeps the default expects the backup to hold everything but the chain. It doesn't hold the hot wallet keys. When a BTCPay store creates a hot wallet, BTCPay calls NBXplorer's wallet generation with SavePrivateKeys = isHotWallet (BTCPayServer/Plugins/Wallets/Controllers/UIStoreOnChainWalletsController.cs:295), and NBXplorer stores the mnemonic, the master key and the account key in its PostgreSQL table nbxv1_metadata (NBXplorer/Controllers/DerivationSchemesController.cs:258-264, NBXplorer/Backend/DbConnectionHelper.cs:200). Nothing else on the node has those keys. btcpaydb holds the store settings and the xpub, and /var/lib/nbxplorer holds settings.config and the API cookie.

After a disk loss the restore brings back BTCPay with its stores and invoices, NBXplorer rescans the xpubs, and every hot wallet comes back watch-only. The coins are still on chain but the key that spends them is gone, unless the operator wrote down the recovery phrase when BTCPay showed it once at creation.

Fix: include the nbxplorer database whenever btcpayserver is enabled. It holds the tracked wallets' transactions and UTXOs, so for a merchant node it's megabytes, not bulk data. If size matters, dump only the metadata table (pg_dump -t nbxv1_metadata nbxplorer) by default and keep the full database behind with-bulk-data. The backups test lists the expected archive members at test/tests.py:864 and should also expect var/backup/postgresql/nbxplorer.sql.gz. I can send the PR with the backups scenario run.

Found by DeepSeek V4.1 Flash 1017 (max) in the review of #143's tree, confirmed by Codex (GPT-6 Astra, xhigh), checked by Fable 5.1 against master ae771dc and the current BTCPay and NBXplorer sources.

Activity

  1. added
    type: bug
    area: modules
    on Oct 24, 2026
  2. added a commit that references this issue on Nov 7, 2026
    329c0be
  3. added a commit that references this issue on Nov 7, 2026
    52f8cf2
  4. added this to the v0.1.5 milestone on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: modulestype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions