2022-07-02 14:33:15 -04:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib; {
|
|
|
|
config = mkIf config.nathan.services.borg.enable {
|
|
|
|
# Add borg to the system packages
|
2022-10-13 22:13:43 -04:00
|
|
|
environment.systemPackages = with pkgs; [ borgbackup ];
|
2022-07-02 14:33:15 -04:00
|
|
|
services.borgbackup.jobs = {
|
|
|
|
rsyncnet = {
|
2022-10-13 22:13:43 -04:00
|
|
|
paths = [ "/home" "/var" "/etc" "/root" ]
|
|
|
|
++ config.nathan.services.borg.extraIncludes;
|
2022-07-02 14:33:15 -04:00
|
|
|
exclude = [
|
|
|
|
"*/.cache"
|
|
|
|
"*/.tmp"
|
|
|
|
"/home/${config.nathan.config.user}/Projects/*/target"
|
|
|
|
"/home/${config.nathan.config.user}/Work/*/target"
|
|
|
|
"/home/${config.nathan.config.user}/.local/share/Steam"
|
|
|
|
"/home/${config.nathan.config.user}/*/Cache"
|
|
|
|
"/home/*/Downloads"
|
2022-07-04 17:41:18 -04:00
|
|
|
"/var/dislocker"
|
2022-09-27 00:25:38 -04:00
|
|
|
"/var/cache"
|
|
|
|
] ++ config.nathan.services.borg.extraExcludes;
|
2022-10-13 22:13:43 -04:00
|
|
|
repo =
|
|
|
|
"${config.nathan.services.borg.location}/${config.networking.hostName}";
|
2022-07-02 14:33:15 -04:00
|
|
|
encryption = {
|
|
|
|
mode = "repokey-blake2";
|
|
|
|
passCommand = "cat ${config.nathan.services.borg.passwordFile}";
|
|
|
|
};
|
|
|
|
environment.BORG_RSH = "ssh -i ${config.nathan.services.borg.sshKey}";
|
|
|
|
compression = "auto,zstd";
|
|
|
|
startAt = config.nathan.services.borg.startAt;
|
2023-06-18 16:33:10 -04:00
|
|
|
prune.keep = if config.nathan.services.borg.keepForever then {
|
2022-07-02 14:33:15 -04:00
|
|
|
within = "7d"; # Keep all archives for the past week
|
|
|
|
daily = 1; # Keep 1 snapshot a day for 2 weeks
|
|
|
|
weekly = 4; # Keep 1 snapshot a week for 4 weeks
|
|
|
|
monthly = -1; # Keep unlimited monthly backups
|
2023-06-18 16:33:10 -04:00
|
|
|
} else {
|
|
|
|
within = "7d"; # Keep all archives for the past week
|
|
|
|
daily = 1; # Keep 1 snapshot a day for 2 weeks
|
|
|
|
weekly = 4; # Keep 1 snapshot a week for 4 weeks
|
|
|
|
monthly = 3; # Keep 3 monthly backups
|
2022-07-02 14:33:15 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|