Get Restic backups working.

This commit is contained in:
Nolan Darilek 2025-04-18 19:38:24 -05:00
parent db901f2bf5
commit 56ca8bd17a

View file

@ -1,32 +1,38 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
services.restic.backups.home = { services.restic.backups.system = {
paths = [ "/home/.zfs/snapshot/restic" ]; paths = [
"/home/.zfs/snapshot/restic"
"/var/.zfs/snapshot/restic"
];
repository = "s3:s3.us-west-001.backblazeb2.com/nolans-nixos-backups/${config.networking.hostName}"; repository = "s3:s3.us-west-001.backblazeb2.com/nolans-nixos-backups/${config.networking.hostName}";
environmentFile = config.age.secrets."restic_b2_${config.networking.hostName}".path; environmentFile = config.age.secrets."restic_b2_${config.networking.hostName}".path;
passwordFile = config.age.secrets."restic_password_${config.networking.hostName}".path; passwordFile = config.age.secrets."restic_password_${config.networking.hostName}".path;
initialize = true; initialize = true;
backupPrepareCommand = "${pkgs.zfs}/bin/zfs snapshot zpool/home@restic"; backupPrepareCommand = ''
backupCleanupCommand = "${pkgs.zfs}/bin/zfs destroy zpool/home@restic"; #!${pkgs.bash}/bin/sh
timerConfig = { ${pkgs.zfs}/bin/zfs snapshot zpool/home@restic
OnCalendar = "hourly"; ${pkgs.zfs}/bin/zfs snapshot zpool/var@restic
Persistent = true; '';
}; backupCleanupCommand = ''
}; #!${pkgs.bash}/bin/sh
services.restic.backups.var = { ${pkgs.zfs}/bin/zfs destroy zpool/home@restic
paths = [ "/var/.zfs/snapshot/restic" ]; ${pkgs.zfs}/bin/zfs destroy zpool/var@restic
repository = "s3:s3.us-west-001.backblazeb2.com/nolans-nixos-backups/${config.networking.hostName}"; '';
environmentFile = config.age.secrets."restic_b2_${config.networking.hostName}".path; timerConfig.OnCalendar = "hourly";
passwordFile = config.age.secrets."restic_password_${config.networking.hostName}".path; pruneOpts = [
initialize = true; "--keep-daily 7"
backupPrepareCommand = "${pkgs.zfs}/bin/zfs snapshot zpool/var@restic"; "--keep-weekly 5"
backupCleanupCommand = "${pkgs.zfs}/bin/zfs destroy zpool/var@restic"; "--keep-monthly 12"
timerConfig = { "--keep-yearly 2"
OnCalendar = "hourly"; ];
Persistent = true;
};
}; };
systemd.tmpfiles.rules = [
"d /mnt/restic 0700 root root"
];
age.secrets."restic_b2_${config.networking.hostName}".file = age.secrets."restic_b2_${config.networking.hostName}".file =
../secrets/restic_b2_${config.networking.hostName}.age; ../secrets/restic_b2_${config.networking.hostName}.age;
age.secrets."restic_password_${config.networking.hostName}".file = age.secrets."restic_password_${config.networking.hostName}".file =