os/shared/core/backups.nix

37 lines
1 KiB
Nix
Raw Permalink Normal View History

2023-06-15 20:29:20 +02:00
{ pkgs, lib, config, ... }:
let cfg = config.custom.backups;
in with lib; {
options.custom.backups = {
enable = mkEnableOption "Automatic backups to Backblaze";
bucket = mkOption {
type = types.str;
default = "ezri-${config.networking.hostName}-backups";
};
};
config = lib.mkIf (cfg.enable) {
services.duplicity = {
enable = true;
secretFile = config.age.secrets."backblaze".path;
2023-06-17 07:32:00 +02:00
frequency = null; # We set this later
root = "/home";
fullIfOlderThan = "1M";
2023-06-15 20:29:20 +02:00
exclude = [
"/home/**/.config"
"/home/**/.cache"
"/home/**/.cargo"
# NixOS configuration, we keep that elsewhere.
"/home/**/os"
];
targetUrl = "b2://005c7170636d5ef0000000001@${cfg.bucket}";
};
2023-06-17 07:32:00 +02:00
systemd.services.duplicity.wants = ["network.target"];
systemd.timers.duplicity.timerConfig."OnBootSec" = "20m";
systemd.timers.duplicity.timerConfig."OnCalendar" = "daily";
systemd.timers.duplicity.timerConfig."Persistent" = true;
2023-06-15 20:29:20 +02:00
};
2023-06-17 07:32:00 +02:00
}