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"
},
"locked": {
"lastModified": 1658751516,
"narHash": "sha256-Y/3dHoTjbvYBtWd+TTBQJUIgDPO9d+Gqt05C5dyR7E4=",
"lastModified": 1659484873,
"narHash": "sha256-6VoPiGyDdjBHOJ3IpS24lY1lrDiOHeuEefOFI0qz3WE=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "dbed4c794d20d51027fc1107f063ec5be027dafc",
"rev": "d8d9ff0b2df77defa10375c6665b51f0251c34d6",
"type": "github"
},
"original": {
@ -134,11 +134,11 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1658346836,
"narHash": "sha256-c9BZZbi0tqCQ4j6CMVDlsut3Q3ET1Fezf+qIslCfkhs=",
"lastModified": 1659375853,
"narHash": "sha256-aiMfO6U1w1u93vB+5qCHCQDZKgpJ7qs4GJOQvI3CN/4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a1fe662eb26ffc2a036b37c4670392ade632c413",
"rev": "511f6a5c3248f9019a41e70c1891484de2bc906c",
"type": "github"
},
"original": {
@ -150,11 +150,11 @@
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1658737577,
"narHash": "sha256-xosJ5nJT9HX+b6UWsSX6R+ap4AdZOCrl/r+IKFp2ASQ=",
"lastModified": 1659305579,
"narHash": "sha256-SFeQTmh7hc9Y2fSkooHaoS8mDfPa04sfmUCtQ8MA6Pg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5a0e0d73b944157328d54c4ded1cf2f0146a86a5",
"rev": "5857574d45925585baffde730369414319228a84",
"type": "github"
},
"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
mail_config = (import ./mailserver/config.nix { });
@ -18,21 +18,46 @@ let
OnBootSec = "1m";
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 {
services.restic.backups.hetzner-vm = {
user = backupUser;
paths = backupPaths;
inherit timerConfig;
repository = "b2:Backups-HetznerVM:/";
passwordFile = "/secrets/restic-password";
environmentFile = "/secrets/restic-env";
};
services.restic.backups.cassie-hetzner-vm = {
user = backupUser;
paths = backupPaths;
inherit timerConfig;
repository = "b2:Cryptidz-Backup:HetznerVM";
passwordFile = "/secrets/restic-password-cassie";
environmentFile = "/secrets/restic-env-cassie";
};
environment.systemPackages = restic_commands;
services.restic.backups.hetzner-vm = lib.mkMerge [
{
user = backupUser;
paths = backupPaths;
inherit timerConfig;
}
repos.Chaos-Backups-HetznerVM
];
services.restic.backups.cassie-hetzner-vm = lib.mkMerge [
{
user = backupUser;
paths = backupPaths;
inherit timerConfig;
}
repos.Cassie-Backups-HetznerVM
];
}

View file

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