From 24819a7f566541ddf923b9fb0b5e7c89463d2857 Mon Sep 17 00:00:00 2001 From: emily Date: Sat, 9 Nov 2024 22:05:02 +0100 Subject: [PATCH] restic: add timer option --- config/hosts/florp/configuration.nix | 5 +++++ config/services/akkoma/default.nix | 5 ++--- modules/restic/default.nix | 12 ++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/config/hosts/florp/configuration.nix b/config/hosts/florp/configuration.nix index 365cfd5..c258a57 100644 --- a/config/hosts/florp/configuration.nix +++ b/config/hosts/florp/configuration.nix @@ -16,9 +16,14 @@ kyouma.restic = { enable = true; remoteUser = "zh3485s1"; + timerConfig = { + OnCalendar = "hourly"; + Persistent = true; + }; paths = [ "/var/lib/akkoma" "/var/lib/postgresql" + "/var/lib/secrets" ]; }; systemd.network.networks."98-eth-default" = { diff --git a/config/services/akkoma/default.nix b/config/services/akkoma/default.nix index 4e8eba8..7f7b4fa 100644 --- a/config/services/akkoma/default.nix +++ b/config/services/akkoma/default.nix @@ -238,11 +238,10 @@ services.nginx = { clientMaxBodySize = "256m"; commonHttpConfig = '' - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/err.log warn; + access_log off; proxy_cache_path /var/cache/nginx/akkoma-media-cache - levels= keys_zone=akkoma_media_cache:32m max_size=64g + levels= keys_zone=akkoma_media_cache:64m max_size=64g inactive=1y use_temp_path=off; ''; }; diff --git a/modules/restic/default.nix b/modules/restic/default.nix index 226001f..2661253 100644 --- a/modules/restic/default.nix +++ b/modules/restic/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: let +{ config, lib, pkgs, utils, ... }: let cfg = config.kyouma.restic; in { options.kyouma.restic = let @@ -40,6 +40,14 @@ in { type = types.nonEmptyStr; default = "${config.networking.hostName}-backup"; }; + timerConfig = mkOption { + description = "timer config"; + type = with types; nullOr (attrsOf utils.systemdUtils.unitOptions.unitOption); + default = { + OnCalendar = "daily"; + Persistent = true; + }; + }; }; config = lib.mkIf cfg.enable { sops.secrets."restic/${cfg.remoteUser}/password" = { @@ -50,7 +58,7 @@ in { }; services.restic.backups."${config.networking.hostName}-${cfg.remote}" = { - inherit (cfg) paths user pruneOpts; + inherit (cfg) paths user pruneOpts timerConfig; initialize = true; repository = "sftp:${cfg.remoteUser}@${cfg.remote}:${cfg.repo}"; passwordFile = config.sops.secrets."restic/${cfg.remoteUser}/password".path;