backup nixos containers on vpsfree

This commit is contained in:
Cyryl Płotnicki 2023-12-23 13:46:39 +00:00
parent 0fa7c214e8
commit 31b448d615

View file

@ -4,7 +4,7 @@
... ...
}: let }: let
genericBackupPath = "/var/lib/backups/"; genericBackupPath = "/var/lib/backups/";
containersBackupPath = "${genericBackupPath}/oci-containers/"; nixosContainersBackupPath = "/var/lib/nixos-containers/";
in rec { in rec {
environment.systemPackages = with pkgs; [restic]; environment.systemPackages = with pkgs; [restic];
@ -23,24 +23,28 @@ in rec {
"/var/lib/foundryvtt" "/var/lib/foundryvtt"
"/var/lib/gitea" "/var/lib/gitea"
"/var/lib/mastodon" "/var/lib/mastodon"
"${containersBackupPath}" "${nixosContainersBackupPath}"
]; ];
repository = "b2:cyplo-restic-vpsfree"; repository = "b2:cyplo-restic-vpsfree";
backupPrepareCommand = '' backupPrepareCommand = ''
mkdir -p ${containersBackupPath}/
systemctl stop container@mastodon.service systemctl stop container@mastodon.service
${pkgs.podman}/bin/podman volume export woodpecker-server-data -o ${containersBackupPath}/woodpecker.tar
''; '';
backupCleanupCommand = '' backupCleanupCommand = ''
systemctl start container@mastodon.service systemctl start container@mastodon.service
''; '';
timerConfig = {OnCalendar = "daily";}; timerConfig = {OnCalendar = "daily";};
environmentFile = "${config.sops.secrets.restic-backups-b2-environment.path}"; environmentFile = "${config.sops.secrets.restic-backups-b2-environment.path}";
extraBackupArgs = [
"--exclude='cache'"
];
}; };
}; };
systemd.services.restic-backups-b2 = { systemd.services.restic-backups-b2 = {
environment = {GOMAXPROCS = "1";}; environment = {
GOMAXPROCS = "1";
GOGC = "20";
};
serviceConfig = { serviceConfig = {
Nice = 19; Nice = 19;
IOSchedulingClass = "idle"; IOSchedulingClass = "idle";