backup shenanigan

This commit is contained in:
ChaotiCryptidz 2022-08-04 16:58:49 +01:00
parent 184e8b9274
commit 96d8987296
No known key found for this signature in database
5 changed files with 56 additions and 26 deletions

View file

@ -60,11 +60,11 @@
"utils": "utils_2" "utils": "utils_2"
}, },
"locked": { "locked": {
"lastModified": 1658751516, "lastModified": 1659484873,
"narHash": "sha256-Y/3dHoTjbvYBtWd+TTBQJUIgDPO9d+Gqt05C5dyR7E4=", "narHash": "sha256-6VoPiGyDdjBHOJ3IpS24lY1lrDiOHeuEefOFI0qz3WE=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "dbed4c794d20d51027fc1107f063ec5be027dafc", "rev": "d8d9ff0b2df77defa10375c6665b51f0251c34d6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -134,11 +134,11 @@
}, },
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1658346836, "lastModified": 1659375853,
"narHash": "sha256-c9BZZbi0tqCQ4j6CMVDlsut3Q3ET1Fezf+qIslCfkhs=", "narHash": "sha256-aiMfO6U1w1u93vB+5qCHCQDZKgpJ7qs4GJOQvI3CN/4=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a1fe662eb26ffc2a036b37c4670392ade632c413", "rev": "511f6a5c3248f9019a41e70c1891484de2bc906c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -150,11 +150,11 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1658737577, "lastModified": 1659305579,
"narHash": "sha256-xosJ5nJT9HX+b6UWsSX6R+ap4AdZOCrl/r+IKFp2ASQ=", "narHash": "sha256-SFeQTmh7hc9Y2fSkooHaoS8mDfPa04sfmUCtQ8MA6Pg=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5a0e0d73b944157328d54c4ded1cf2f0146a86a5", "rev": "5857574d45925585baffde730369414319228a84",
"type": "github" "type": "github"
}, },
"original": { "original": {

1
home/apps/rclone.nix Normal file
View file

@ -0,0 +1 @@
{ config, pkgs, ... }: { home.packages = with pkgs; [ rclone ]; }

1
home/apps/restic.nix Normal file
View file

@ -0,0 +1 @@
{ config, pkgs, ... }: { home.packages = with pkgs; [ restic ]; }

View file

@ -1,4 +1,4 @@
_: { lib, pkgs, ... }:
let let
mail_config = (import ./mailserver/config.nix { }); mail_config = (import ./mailserver/config.nix { });
@ -18,21 +18,46 @@ let
OnBootSec = "1m"; OnBootSec = "1m";
OnCalendar = "daily"; OnCalendar = "daily";
}; };
repos = {
Chaos-Backups-HetznerVM = {
repository = "b2:Chaos-Backups:HetznerVM";
passwordFile = "/secrets/restic-Chaos-Backups-HetznerVM-password";
environmentFile = "/secrets/restic-Chaos-Backups-HetznerVM-env";
};
Cassie-Backups-HetznerVM = {
repository = "b2:Cryptidz-Backup:HetznerVM";
passwordFile = "/secrets/restic-Cassie-Backups-HetznerVM-password";
environmentFile = "/secrets/restic-Cassie-Backups-HetznerVM-env";
};
};
restic_commands = lib.mapAttrsToList (repoName: repoInfo: (
# nya
pkgs.writeShellScriptBin "restic-${repoName}" ''
env \
$(cat ${repoInfo.environmentFile}) \
RESTIC_PASSWORD_FILE=${repoInfo.passwordFile} \
RESTIC_REPOSITORY=${repoInfo.repository} \
${pkgs.restic}/bin/restic $@
''
)) repos;
in { in {
services.restic.backups.hetzner-vm = { environment.systemPackages = restic_commands;
user = backupUser;
paths = backupPaths; services.restic.backups.hetzner-vm = lib.mkMerge [
inherit timerConfig; {
repository = "b2:Backups-HetznerVM:/"; user = backupUser;
passwordFile = "/secrets/restic-password"; paths = backupPaths;
environmentFile = "/secrets/restic-env"; inherit timerConfig;
}; }
services.restic.backups.cassie-hetzner-vm = { repos.Chaos-Backups-HetznerVM
user = backupUser; ];
paths = backupPaths; services.restic.backups.cassie-hetzner-vm = lib.mkMerge [
inherit timerConfig; {
repository = "b2:Cryptidz-Backup:HetznerVM"; user = backupUser;
passwordFile = "/secrets/restic-password-cassie"; paths = backupPaths;
environmentFile = "/secrets/restic-env-cassie"; inherit timerConfig;
}; }
repos.Cassie-Backups-HetznerVM
];
} }

View file

@ -83,6 +83,9 @@ in {
home.apps.mullvad home.apps.mullvad
home.apps.aria2 home.apps.aria2
home.apps.aegisub home.apps.aegisub
home.apps.rclone
home.apps.restic
home.programming.editors.vscode home.programming.editors.vscode
home.programming.languages.go home.programming.languages.go