From 768a717a8b7c84c260225b8b44c48b2fcfd75fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Tue, 3 Mar 2026 18:43:40 +0100 Subject: [PATCH] Enable rotating gitea backups --- m/tent/gitea.nix | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/m/tent/gitea.nix b/m/tent/gitea.nix index 5c458306..53c3b850 100644 --- a/m/tent/gitea.nix +++ b/m/tent/gitea.nix @@ -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