forked from rarias/jungle
Enable rotating gitea backups
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user