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

56 lines
1.3 KiB
Nix
Raw Normal View History

2023-08-01 20:53:25 +01:00
{
pkgs,
host_secrets,
...
}: let
secrets = host_secrets;
backupPrepareCommand = "${
(pkgs.writeShellScriptBin "backupPrepareCommand" ''
systemctl start postgresqlBackup-quassel --wait
'')
}/bin/backupPrepareCommand";
in {
environment.systemPackages = with pkgs; [
restic
(pkgs.writeShellScriptBin "restic-quassel" ''
env \
RESTIC_PASSWORD_FILE=${secrets.quassel_restic_password.path} \
$(cat ${secrets.quassel_restic_env.path}) \
${pkgs.restic}/bin/restic $@
'')
];
services.restic.backups.quassel = {
user = "root";
paths = [
"/var/backup/postgresql"
"/home/quassel/.config/quassel-irc.org"
];
# 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/Quassel";
passwordFile = "${secrets.quassel_restic_password.path}";
environmentFile = "${secrets.quassel_restic_env.path}";
pruneOpts = [
"--keep-last 5"
];
timerConfig = {
OnBootSec = "1m";
OnCalendar = "daily";
};
inherit backupPrepareCommand;
};
services.postgresqlBackup = {
enable = true;
backupAll = false;
databases = ["quassel"];
compression = "zstd";
};
}