nixos/roles/restic.nix

38 lines
1.2 KiB
Nix
Raw Permalink Normal View History

2025-03-31 16:12:29 -05:00
{ config, pkgs, ... }:
{
2025-04-18 19:38:24 -05:00
services.restic.backups.system = {
paths = [
"/home/.zfs/snapshot/restic"
"/var/.zfs/snapshot/restic"
];
2025-03-31 16:12:29 -05:00
repository = "s3:s3.us-west-001.backblazeb2.com/nolans-nixos-backups/${config.networking.hostName}";
environmentFile = config.age.secrets."restic_b2_${config.networking.hostName}".path;
passwordFile = config.age.secrets."restic_password_${config.networking.hostName}".path;
initialize = true;
2025-04-18 19:38:24 -05:00
backupPrepareCommand = ''
#!${pkgs.bash}/bin/sh
${pkgs.zfs}/bin/zfs snapshot zpool/home@restic
${pkgs.zfs}/bin/zfs snapshot zpool/var@restic
'';
backupCleanupCommand = ''
#!${pkgs.bash}/bin/sh
${pkgs.zfs}/bin/zfs destroy zpool/home@restic
${pkgs.zfs}/bin/zfs destroy zpool/var@restic
'';
timerConfig.OnCalendar = "hourly";
pruneOpts = [
2025-04-19 07:20:40 -05:00
"--keep-hourly 24"
2025-04-18 19:38:24 -05:00
"--keep-daily 7"
"--keep-weekly 5"
"--keep-monthly 12"
"--keep-yearly 2"
];
2025-03-31 16:12:29 -05:00
};
2025-04-18 19:38:24 -05:00
2025-03-31 16:12:29 -05:00
age.secrets."restic_b2_${config.networking.hostName}".file =
../secrets/restic_b2_${config.networking.hostName}.age;
age.secrets."restic_password_${config.networking.hostName}".file =
../secrets/restic_password_${config.networking.hostName}.age;
}