Enable rotating gitea backups

This commit is contained in:
2026-03-03 18:43:40 +01:00
parent 84a5cb09ee
commit 768a717a8b

View File

@@ -26,6 +26,44 @@
SENDMAIL_ARGS = "--";
};
};
dump = {
enable = false; # Do not enable NixOS module, use our custom systemd script below
backupDir = "/vault/gitea";
};
};
systemd.services.gitea-dump-rotating = let
cfg = config.services.gitea;
exe = lib.getExe cfg.package;
in {
description = "gitea dump rotation";
after = [ "gitea.service" ];
path = [ cfg.package ];
environment = {
USER = cfg.user;
HOME = cfg.stateDir;
GITEA_WORK_DIR = cfg.stateDir;
GITEA_CUSTOM = cfg.customDir;
};
serviceConfig = {
Type = "oneshot";
User = cfg.user;
WorkingDirectory = cfg.dump.backupDir;
};
script = ''
${exe} dump --type ${cfg.dump.type} --file "gitea-dump-$(date +%a).${cfg.dump.type}"
'';
};
systemd.timers.gitea-dump-rotating = {
description = "Update timer for gitea-dump-rotating";
partOf = [ "gitea-dump-rotating.service" ];
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = config.services.gitea.dump.interval;
};
# Allow gitea user to send mail