75 lines
1.9 KiB
Nix
75 lines
1.9 KiB
Nix
{ lib, config, ... }:
|
|
let
|
|
enabled = config.mod.restic.enable;
|
|
in
|
|
{
|
|
options = {
|
|
mod.restic = {
|
|
enable = lib.mkEnableOption "Enable restic";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf enabled {
|
|
fileSystems."/home/alex/backup" = {
|
|
device = "/dev/disk/by-uuid/34601701-65e6-4b2c-ac4d-8bef3dfd743f";
|
|
fsType = "ext4";
|
|
options = [ "nofail" ];
|
|
};
|
|
|
|
services = {
|
|
restic.backups = {
|
|
"sync-to-external" = {
|
|
initialize = true;
|
|
|
|
passwordFile = config.age.secrets.restic-password.path;
|
|
|
|
paths = [ "/home/alex/sync" ];
|
|
repository = "/home/alex/backup/restic";
|
|
|
|
timerConfig = {
|
|
OnCalendar = "*-*-* 0/12:00:00"; # Every 12th hour, i.e. twice a day
|
|
Persistent = true;
|
|
};
|
|
|
|
pruneOpts = [
|
|
"--keep-daily 1"
|
|
"--keep-weekly 7"
|
|
"--keep-yearly 12"
|
|
];
|
|
};
|
|
|
|
"sync-to-cloud" = {
|
|
initialize = true;
|
|
|
|
passwordFile = config.age.secrets.restic-password.path;
|
|
environmentFile = config.age.secrets.restic-cloud-sync-key.path;
|
|
repositoryFile = config.age.secrets.restic-cloud-sync-repository.path;
|
|
|
|
paths = [ "/home/alex/sync" ];
|
|
exclude = [ "/home/alex/sync/reading-material" ];
|
|
|
|
timerConfig = {
|
|
OnCalendar = "*-*-* 0/12:00:00"; # Every 12th hour, i.e. twice a day
|
|
Persistent = true;
|
|
};
|
|
|
|
pruneOpts = [
|
|
"--keep-daily 1"
|
|
"--keep-weekly 7"
|
|
"--keep-yearly 12"
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
age = {
|
|
secrets = {
|
|
"restic-password".file = ../../../../secrets/backwards/restic-password.age;
|
|
"restic-cloud-sync-key".file = ../../../../secrets/backwards/restic-cloud-sync-key.age;
|
|
"restic-cloud-sync-repository".file =
|
|
../../../../secrets/backwards/restic-cloud-sync-repository.age;
|
|
};
|
|
};
|
|
};
|
|
}
|