2023-05-06 08:27:43 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
let
|
2022-12-02 22:13:18 +00:00
|
|
|
genericBackupPath = "/var/lib/backups/";
|
|
|
|
containersBackupPath = "${genericBackupPath}/oci-containers/";
|
|
|
|
in rec {
|
2023-05-06 08:27:43 +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 = {
|
|
|
|
passwordFile = "/run/secrets/restic-backups-b2-repo-password";
|
2022-12-02 22:13:18 +00:00
|
|
|
paths = [
|
|
|
|
"/var/lib/foundryvtt"
|
|
|
|
"/var/lib/gitea"
|
|
|
|
"/var/lib/mastodon"
|
|
|
|
"${containersBackupPath}"
|
|
|
|
];
|
2022-08-20 10:13:25 +01:00
|
|
|
repository = "b2:cyplo-restic-vpsfree";
|
2022-12-02 22:13:18 +00:00
|
|
|
backupPrepareCommand = ''
|
|
|
|
mkdir -p ${containersBackupPath}/
|
2023-05-25 12:11:24 +01:00
|
|
|
systemctl stop container@mastodon.service
|
2022-12-02 22:13:18 +00:00
|
|
|
${pkgs.podman}/bin/podman volume export woodpecker-server-data -o ${containersBackupPath}/woodpecker.tar
|
|
|
|
'';
|
2023-05-25 12:11:24 +01:00
|
|
|
backupCleanupCommand = ''
|
|
|
|
systemctl start container@mastodon.service
|
|
|
|
'';
|
2023-05-27 19:44:55 +01:00
|
|
|
timerConfig = { OnCalendar = "daily"; };
|
2023-05-06 08:27:43 +01:00
|
|
|
environmentFile =
|
|
|
|
"${config.sops.secrets.restic-backups-b2-environment.path}";
|
2022-08-20 10:13:25 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-05-06 08:27:43 +01:00
|
|
|
systemd.services.restic-backups-b2 = {
|
|
|
|
environment = { GOMAXPROCS = "1"; };
|
|
|
|
serviceConfig = {
|
|
|
|
Nice = 19;
|
|
|
|
IOSchedulingClass = "idle";
|
|
|
|
};
|
2022-08-20 10:13:25 +01:00
|
|
|
};
|
|
|
|
}
|