backups: add btcpayserver database

This commit is contained in:
nixbitcoin 2020-09-22 16:40:20 +00:00
parent 0784e2d479
commit 73f4275d2a
No known key found for this signature in database
GPG Key ID: DD11F9AD5308B3BA
3 changed files with 22 additions and 4 deletions

View File

@ -20,6 +20,7 @@ let
${config.services.btcpayserver.dataDir} ${config.services.btcpayserver.dataDir}
${config.services.joinmarket.dataDir} ${config.services.joinmarket.dataDir}
/secrets/jm-wallet-seed /secrets/jm-wallet-seed
${config.services.postgresqlBackup.location}/btcpaydb.sql.gz
/var/lib/tor /var/lib/tor
# Extra files # Extra files
${cfg.extraFiles} ${cfg.extraFiles}
@ -69,8 +70,8 @@ in {
}; };
}; };
config = mkMerge [ config = mkIf (cfg.enable && cfg.program == "duplicity") (mkMerge [
(mkIf (cfg.enable && cfg.program == "duplicity") { {
environment.systemPackages = [ pkgs.duplicity ]; environment.systemPackages = [ pkgs.duplicity ];
services.duplicity = { services.duplicity = {
@ -85,7 +86,17 @@ in {
}; };
nix-bitcoin.secrets.backup-encryption-env.user = "root"; nix-bitcoin.secrets.backup-encryption-env.user = "root";
}
(mkIf config.services.btcpayserver.enable {
services.postgresqlBackup = {
enable = true;
databases = [ "btcpaydb" ];
startAt = [];
};
systemd.services.duplicity = rec {
wants = [ "postgresqlBackup-btcpaydb.service" ];
after = wants;
};
}) })
]; ]);
} }

View File

@ -166,6 +166,10 @@ def run_tests(extra_tests):
"export $(cat /secrets/backup-encryption-env); duplicity list-current-files 'file:///var/lib/localBackups'", "export $(cat /secrets/backup-encryption-env); duplicity list-current-files 'file:///var/lib/localBackups'",
"var/lib/bitcoind/wallet.dat", "var/lib/bitcoind/wallet.dat",
) )
assert_matches(
"export $(cat /secrets/backup-encryption-env); duplicity list-current-files 'file:///var/lib/localBackups'",
"var/backup/postgresql/btcpaydb.sql.gz",
)
### Check that all extra_tests have been run ### Check that all extra_tests have been run
assert len(extra_tests) == 0 assert len(extra_tests) == 0

View File

@ -19,6 +19,9 @@ import ./make-test.nix rec {
# hardened # hardened
]; ];
# needed because duplicity requires 270 MB of free temp space, regardless of backup size.
virtualisation.diskSize = 1024;
nix-bitcoin.netns-isolation.enable = (scenario == "withnetns"); nix-bitcoin.netns-isolation.enable = (scenario == "withnetns");
services.bitcoind.extraConfig = mkForce "connect=0"; services.bitcoind.extraConfig = mkForce "connect=0";