-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
22c3fd5 backups: add feature test (nixbitcoin) e4fb7a5 backups: add module (nixbitcoin) Pull request description: ACKs for top commit: jonasnick: ACK 22c3fd5 Tree-SHA512: 625c1fe4f12ea881b5adb04e07187eae60451402462cd3032b2f741b3f23ee73ea68b98aeb8cfd9206890e8227229cb4ab0cdb5f7935f34fc33fc50dc5df26c9
- Loading branch information
Showing
9 changed files
with
147 additions
and
5 deletions.
There are no files selected for viewing
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,87 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
cfg = config.services.backups; | ||
filelist = pkgs.writeText "filelist.txt" '' | ||
${optionalString (!cfg.with-bulk-data) "- ${config.services.bitcoind.dataDir}/blocks"} | ||
${optionalString (!cfg.with-bulk-data) "- ${config.services.bitcoind.dataDir}/chainstate"} | ||
${config.services.bitcoind.dataDir} | ||
${config.services.clightning.dataDir} | ||
${config.services.lnd.dataDir} | ||
/secrets/lnd-seed-mnemonic | ||
${optionalString (!cfg.with-bulk-data) "- ${config.services.liquidd.dataDir}/*/blocks"} | ||
${optionalString (!cfg.with-bulk-data) "- ${config.services.liquidd.dataDir}/*/chainstate"} | ||
${config.services.liquidd.dataDir} | ||
${optionalString cfg.with-bulk-data "${config.services.electrs.dataDir}"} | ||
${config.services.lightning-charge.dataDir} | ||
/var/lib/tor | ||
# Extra files | ||
${cfg.extraFiles} | ||
# Exclude all unspecified files and directories | ||
- / | ||
''; | ||
|
||
in { | ||
options.services.backups = { | ||
enable = mkEnableOption "Backups service"; | ||
program = mkOption { | ||
type = types.enum [ "duplicity" ]; | ||
default = "duplicity"; | ||
description = '' | ||
Program with which to do backups. | ||
''; | ||
}; | ||
with-bulk-data = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = '' | ||
Whether to also backup Bitcoin blockchain and other bulk data. | ||
''; | ||
}; | ||
destination = mkOption { | ||
type = types.str; | ||
default = "file:///var/lib/localBackups"; | ||
description = '' | ||
Where to back up to. | ||
''; | ||
}; | ||
frequency = mkOption { | ||
type = types.nullOr types.str; | ||
default = null; | ||
description = '' | ||
Run backup with the given frequency. If null, do not run automatically. | ||
''; | ||
}; | ||
extraFiles = mkOption { | ||
type = types.lines; | ||
default = ""; | ||
example = '' | ||
/var/lib/nginx | ||
''; | ||
description = "Additional files to be appended to filelist."; | ||
}; | ||
}; | ||
|
||
config = mkMerge [ | ||
(mkIf (cfg.enable && cfg.program == "duplicity") { | ||
environment.systemPackages = [ pkgs.duplicity ]; | ||
|
||
services.duplicity = { | ||
enable = true; | ||
extraFlags = [ | ||
"--include-filelist" "${filelist}" | ||
"--full-if-older-than" "1M" | ||
]; | ||
targetUrl = "${cfg.destination}"; | ||
frequency = cfg.frequency; | ||
secretFile = "${config.nix-bitcoin.secretsDir}/backup-encryption-env"; | ||
}; | ||
|
||
nix-bitcoin.secrets.backup-encryption-env.user = "root"; | ||
|
||
}) | ||
]; | ||
} |
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
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
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
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