dotfiles/nixos/boxes/cupsnet/backups.nix

70 lines
1.9 KiB
Nix
Raw Normal View History

2024-06-28 19:23:39 +01:00
{
config,
pkgs,
...
}: let
2022-12-02 22:13:18 +00:00
genericBackupPath = "/var/lib/backups/";
2023-12-23 13:46:39 +00:00
nixosContainersBackupPath = "/var/lib/nixos-containers/";
2022-12-02 22:13:18 +00:00
in rec {
2024-06-28 19:23:39 +01:00
environment.systemPackages = with pkgs; [restic];
2022-08-20 10:13:25 +01:00
sops.secrets."restic-backups-b2-repo-password" = {
sopsFile = ./restic.sops.yaml;
};
sops.secrets."restic-backups-b2-environment" = {
sopsFile = ./restic-environment.sops;
format = "binary";
path = "/etc/nixos/secrets/b2-env";
};
services = {
restic.backups.b2 = {
2024-04-21 12:18:05 +01:00
passwordFile = config.sops.secrets."restic-backups-b2-repo-password".path;
2022-12-02 22:13:18 +00:00
paths = [
"/var/lib/foundryvtt"
"/var/lib/gitea"
"/var/lib/mastodon"
2024-04-21 12:18:05 +01:00
"/var/lib/postgresql"
"/var/lib/private/cryptpad/"
2023-12-23 13:46:39 +00:00
"${nixosContainersBackupPath}"
2022-12-02 22:13:18 +00:00
];
2024-04-21 12:18:05 +01:00
repository = "b2:cyplo-backup-cupsnet";
2022-12-02 22:13:18 +00:00
backupPrepareCommand = ''
2024-04-21 12:18:05 +01:00
systemctl stop container@foundryvtt.service
systemctl stop cryptpad.service
systemctl stop forgejo.service
2024-06-28 19:23:39 +01:00
systemctl stop mastodon*
2024-04-21 12:18:05 +01:00
systemctl stop postgresql.service
2022-12-02 22:13:18 +00:00
'';
backupCleanupCommand = ''
2024-04-21 12:18:05 +01:00
systemctl start postgresql.service
systemctl start forgejo.service
systemctl start cryptpad.service
systemctl start container@foundryvtt.service
2024-06-28 19:23:39 +01:00
systemctl start --all mastodon*
'';
2024-06-28 19:23:39 +01:00
timerConfig = {OnCalendar = "daily";};
environmentFile = "${config.sops.secrets.restic-backups-b2-environment.path}";
exclude = ["cache"];
2023-12-23 16:47:23 +00:00
pruneOpts = [
"--keep-hourly 25"
"--keep-daily 8"
"--keep-weekly 5"
"--keep-monthly 13"
"--keep-yearly 2"
];
2024-06-28 19:23:39 +01:00
checkOpts = ["--with-cache"];
2022-08-20 10:13:25 +01:00
};
};
systemd.services.restic-backups-b2 = {
2023-12-23 13:46:39 +00:00
environment = {
GOMAXPROCS = "1";
GOGC = "20";
};
serviceConfig = {
Nice = 19;
IOSchedulingClass = "idle";
};
2022-08-20 10:13:25 +01:00
};
}