2022-08-04 21:53:51 +01:00
|
|
|
{ lib, config, pkgs, ... }:
|
2021-12-31 12:53:52 +00:00
|
|
|
let
|
2022-11-15 13:42:28 +00:00
|
|
|
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 postgresqlBackup --wait
|
|
|
|
'')
|
|
|
|
}/bin/backupPrepareCommand";
|
2022-11-02 11:32:03 +00:00
|
|
|
in {
|
|
|
|
environment.systemPackages = [
|
|
|
|
(pkgs.writeShellScriptBin "restic-hetzner-vm" ''
|
|
|
|
env \
|
2022-11-15 13:42:28 +00:00
|
|
|
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"
|
|
|
|
# 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"
|
|
|
|
|
|
|
|
# misskey
|
|
|
|
"/home/misskey/misskey-files"
|
|
|
|
"/var/lib/redis-misskey"
|
|
|
|
];
|
|
|
|
|
|
|
|
# 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";
|
2022-11-15 13:42:28 +00:00
|
|
|
passwordFile = "${secrets.restic_password.path}";
|
|
|
|
environmentFile = "${secrets.restic_env.path}";
|
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 = true;
|
|
|
|
compression = "zstd";
|
|
|
|
};
|
2021-12-29 13:17:01 +00:00
|
|
|
}
|