diff options
author | lassulus <git@lassul.us> | 2023-08-31 17:47:17 +0200 |
---|---|---|
committer | lassulus <git@lassul.us> | 2023-08-31 17:47:17 +0200 |
commit | 9bc7ad4afe727660f05c037386d0a00f5625801a (patch) | |
tree | 86abdb349652a78fb70fe3cefafa97ff5cc08c27 /lass/1systems | |
parent | 6592341dc31c6f26422ec3a9fed2e601ab985cfc (diff) |
l prism.r: add backups
Diffstat (limited to 'lass/1systems')
-rw-r--r-- | lass/1systems/prism/backup.nix | 37 | ||||
-rw-r--r-- | lass/1systems/prism/config.nix | 1 |
2 files changed, 38 insertions, 0 deletions
diff --git a/lass/1systems/prism/backup.nix b/lass/1systems/prism/backup.nix new file mode 100644 index 000000000..52b4142b9 --- /dev/null +++ b/lass/1systems/prism/backup.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: +{ + services.postgresqlBackup.enable = true; + + systemd.services.borgbackup-job-hetzner.serviceConfig.ReadWritePaths = [ "/var/log/telegraf" ]; + + services.borgbackup.jobs.hetzner = { + paths = [ + "/var/backup" + ]; + exclude = [ + "*.pyc" + ]; + repo = "u364341@u364341.your-storagebox.de:/./hetzner"; + encryption.mode = "none"; + compression = "auto,zstd"; + startAt = "daily"; + # TODO: change backup key + environment.BORG_RSH = "ssh -oPort=23 -i ${toString <secrets> + "/borgbackup.ssh.id25519"}"; + preHook = '' + set -x + ''; + + postHook = '' + cat > /var/log/telegraf/borgbackup-job-hetzner.service <<EOF + task,frequency=daily last_run=$(date +%s)i,state="$([[ $exitStatus == 0 ]] && echo ok || echo fail)" + EOF + ''; + + prune.keep = { + within = "1d"; # Keep all archives from the last day + daily = 7; + weekly = 4; + monthly = 0; + }; + }; +} diff --git a/lass/1systems/prism/config.nix b/lass/1systems/prism/config.nix index 1faa23ec3..0e58b62b8 100644 --- a/lass/1systems/prism/config.nix +++ b/lass/1systems/prism/config.nix @@ -3,6 +3,7 @@ with import <stockholm/lib>; { imports = [ + ./backup.nix <stockholm/lass> <stockholm/lass/2configs/retiolum.nix> <stockholm/lass/2configs/libvirt.nix> |