encrypt borg repository
also backup to AWS EC2 instance
This commit is contained in:
parent
2804e764f5
commit
914d84ef23
5 changed files with 21 additions and 5 deletions
|
@ -112,6 +112,7 @@
|
||||||
tcpdump
|
tcpdump
|
||||||
lsof
|
lsof
|
||||||
parted
|
parted
|
||||||
|
borgbackup
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,13 @@ let
|
||||||
repositories:
|
repositories:
|
||||||
- path: ${cfg.repoLocation}
|
- path: ${cfg.repoLocation}
|
||||||
label: nfs
|
label: nfs
|
||||||
|
- path: ssh://admin@ec2-3-254-121-39.eu-west-1.compute.amazonaws.com/mnt/data/nfs.borg
|
||||||
|
label: ec2
|
||||||
|
ssh_command: "${pkgs.openssh}/bin/ssh -i ${config.age.secrets."ec2_borg_server.pem".path} -o StrictHostKeychecking=no -o ConnectTimeout=10 -o ConnectionAttempts=3"
|
||||||
keep_daily: 7
|
keep_daily: 7
|
||||||
keep_weekly: 4
|
keep_weekly: 4
|
||||||
keep_monthly: 6
|
keep_monthly: 6
|
||||||
unknown_unencrypted_repo_access_is_ok: true
|
encryption_passcommand: "${pkgs.coreutils}/bin/cat ''${BORG_PASSPHRASE_FILE}"
|
||||||
before_everything:
|
before_everything:
|
||||||
- ${beforeEverything}/bin/beforeEverything
|
- ${beforeEverything}/bin/beforeEverything
|
||||||
postgresql_databases:
|
postgresql_databases:
|
||||||
|
@ -64,7 +67,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
snapshotLocation = lib.mkOption {
|
snapshotLocation = lib.mkOption {
|
||||||
default = "${config.lab.storage.dataMountPoint}/nfs-backup";
|
default = "${config.lab.storage.dataMountPoint}/snapshot-nfs";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = ''
|
description = ''
|
||||||
Location to (temporary) create a snapshot of the subvolume.
|
Location to (temporary) create a snapshot of the subvolume.
|
||||||
|
@ -73,7 +76,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
environment.systemPackages = with pkgs; [ borgbackup postgresql ];
|
environment.systemPackages = with pkgs; [ postgresql ];
|
||||||
# Converted from:
|
# Converted from:
|
||||||
# https://github.com/borgmatic-collective/borgmatic/tree/84823dfb912db650936e3492f6ead7e0e0d32a0f/sample/systemd
|
# https://github.com/borgmatic-collective/borgmatic/tree/84823dfb912db650936e3492f6ead7e0e0d32a0f/sample/systemd
|
||||||
systemd.services.borgmatic = {
|
systemd.services.borgmatic = {
|
||||||
|
@ -94,6 +97,7 @@ in
|
||||||
Restart = "no";
|
Restart = "no";
|
||||||
LogRateLimitIntervalSec = 0;
|
LogRateLimitIntervalSec = 0;
|
||||||
EnvironmentFile = config.age.secrets."database_passwords.env".path;
|
EnvironmentFile = config.age.secrets."database_passwords.env".path;
|
||||||
|
Environment = "BORG_PASSPHRASE_FILE=${config.age.secrets."borg_passphrase".path}";
|
||||||
};
|
};
|
||||||
|
|
||||||
script = "${pkgs.systemd}/bin/systemd-inhibit --who=\"borgmatic\" --what=\"sleep:shutdown\" --why=\"Prevent interrupting scheduled backup\" ${pkgs.borgmatic}/bin/borgmatic --verbosity -2 --syslog-verbosity 1 -c ${borgmaticConfig}";
|
script = "${pkgs.systemd}/bin/systemd-inhibit --who=\"borgmatic\" --what=\"sleep:shutdown\" --why=\"Prevent interrupting scheduled backup\" ${pkgs.borgmatic}/bin/borgmatic --verbosity -2 --syslog-verbosity 1 -c ${borgmaticConfig}";
|
||||||
|
@ -109,8 +113,10 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
age.secrets."database_passwords.env" = {
|
age.secrets = {
|
||||||
file = ../secrets/database_passwords.env.age;
|
"database_passwords.env".file = ../secrets/database_passwords.env.age;
|
||||||
|
"borg_passphrase".file = ../secrets/borg_passphrase.age;
|
||||||
|
"ec2_borg_server.pem".file = ../secrets/ec2_borg_server.pem.age;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
6
nixos/secrets/borg_passphrase.age
Normal file
6
nixos/secrets/borg_passphrase.age
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
age-encryption.org/v1
|
||||||
|
-> ssh-ed25519 aqswPA BWfWJ0Detm+1l0tYnjR9n5rIUBfdHb/wTnZnGoYx6SU
|
||||||
|
gp5vcIXtJpF6KJ0cHJ6GRpHQvxi7ij//1LH0afFoRuo
|
||||||
|
--- exwOM8D5yMcDFp0uzRnbD6TWSgs12WmZo7sKlnHYOwY
|
||||||
|
4Öš¾0
|
||||||
|
e(+×}²½f%Àã^‘ kÀbד{WèŒôVüPänדù:…Å6ý£s
|
BIN
nixos/secrets/ec2_borg_server.pem.age
Normal file
BIN
nixos/secrets/ec2_borg_server.pem.age
Normal file
Binary file not shown.
|
@ -1,3 +1,4 @@
|
||||||
|
# TODO: Just encrypt each file with all hosts' public keys (plus our personal public keys) and deploy when demanded.
|
||||||
let
|
let
|
||||||
pkgs = import <nixpkgs> { };
|
pkgs = import <nixpkgs> { };
|
||||||
lib = pkgs.lib;
|
lib = pkgs.lib;
|
||||||
|
@ -29,6 +30,8 @@ let
|
||||||
"lewis_host_ed25519.age"
|
"lewis_host_ed25519.age"
|
||||||
"lewis_user_ed25519.age"
|
"lewis_user_ed25519.age"
|
||||||
"database_passwords.env.age"
|
"database_passwords.env.age"
|
||||||
|
"borg_passphrase.age"
|
||||||
|
"ec2_borg_server.pem.age"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue