nixfiles/hosts/hetzner-vm/profiles/restic.nix

72 lines
1.7 KiB
Nix
Raw Normal View History

{
lib,
config,
pkgs,
...
}: let
secrets = config.services.secrets.secrets;
2022-11-17 12:06:16 +00:00
mail_config = config.mailserver;
2022-06-22 16:59:41 +01:00
2022-08-12 17:06:50 +01:00
backupPrepareCommand = "${
(pkgs.writeShellScriptBin "backupPrepareCommand" ''
systemctl start ${
lib.concatStringsSep " "
(lib.forEach config.services.postgresqlBackup.databases
(db: "postgresqlBackup-${db}"))
} --wait
'')
}/bin/backupPrepareCommand";
2022-11-02 11:32:03 +00:00
in {
environment.systemPackages = with pkgs; [
restic
2022-11-02 11:32:03 +00:00
(pkgs.writeShellScriptBin "restic-hetzner-vm" ''
env \
RESTIC_PASSWORD_FILE=${secrets.restic_password.path} \
$(cat ${secrets.restic_env.path}) \
2022-11-02 11:32:03 +00:00
${pkgs.restic}/bin/restic $@
'')
];
2022-08-04 21:53:51 +01:00
2022-11-02 11:32:03 +00:00
services.restic.backups.hetzner-vm = {
user = "root";
paths = [
"/var/lib/acme"
2022-11-02 11:32:03 +00:00
# Quassel & Invidious
"/var/backup/postgresql"
"/home/quassel/.config/quassel-irc.org"
2022-08-04 16:58:49 +01:00
2022-11-02 11:32:03 +00:00
# mail
mail_config.vmail_config.directory
mail_config.sieve_directory
mail_config.dkim_directory
"/var/lib/redis-rspamd"
];
# repository is overrided in environmentFile to contain auth
# make sure to keep up to date when changing repository
repository = "rest:https://storage-restic.owo.monster/HetznerVM";
passwordFile = "${secrets.restic_password.path}";
environmentFile = "${secrets.restic_env.path}";
2022-11-02 11:32:03 +00:00
pruneOpts = [
"--keep-last 20"
];
2022-11-02 11:32:03 +00:00
timerConfig = {
OnBootSec = "1m";
OnCalendar = "daily";
};
inherit backupPrepareCommand;
};
2022-08-04 21:53:51 +01:00
services.postgresqlBackup = {
enable = true;
backupAll = false;
databases = ["postgres" "quassel" "roundcube"];
2022-08-04 21:53:51 +01:00
compression = "zstd";
};
2021-12-29 13:17:01 +00:00
}