Tweak borg to remove long-term server backups

This commit is contained in:
Nathan McCarty 2023-06-18 16:33:10 -04:00
parent 6b76c0a4f9
commit 7c995bfdce
Signed by: thatonelutenist
SSH Key Fingerprint: SHA256:hwQEcmak9E6sdU9bXc98RHw/Xd1AhpB5HZT7ZSVJkRM
2 changed files with 10 additions and 1 deletions

View File

@ -81,6 +81,10 @@ in {
description = "How often to run backups"; description = "How often to run backups";
default = "hourly"; default = "hourly";
}; };
keepForever = mkOption {
description = "Keep monthly backups forever";
default = config.nathan.config.isDesktop;
};
}; };
# Nginx # Nginx
nginx = { nginx = {

View File

@ -28,11 +28,16 @@ with lib; {
environment.BORG_RSH = "ssh -i ${config.nathan.services.borg.sshKey}"; environment.BORG_RSH = "ssh -i ${config.nathan.services.borg.sshKey}";
compression = "auto,zstd"; compression = "auto,zstd";
startAt = config.nathan.services.borg.startAt; startAt = config.nathan.services.borg.startAt;
prune.keep = { prune.keep = if config.nathan.services.borg.keepForever then {
within = "7d"; # Keep all archives for the past week within = "7d"; # Keep all archives for the past week
daily = 1; # Keep 1 snapshot a day for 2 weeks daily = 1; # Keep 1 snapshot a day for 2 weeks
weekly = 4; # Keep 1 snapshot a week for 4 weeks weekly = 4; # Keep 1 snapshot a week for 4 weeks
monthly = -1; # Keep unlimited monthly backups monthly = -1; # Keep unlimited monthly backups
} 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
}; };
}; };
}; };