machines/thorite: add more scrapes, alerts; add restic backup;
This commit is contained in:
parent
bf74a01049
commit
bd4d7b5217
4 changed files with 82 additions and 8 deletions
51
machines/thorite/restic.nix
Normal file
51
machines/thorite/restic.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
sqliteBackup = fromPath: toPath: file: ''
|
||||
mkdir -p ${toPath}
|
||||
${lib.getExe pkgs.sqlite} ${fromPath} ".backup '${toPath}/${file}'"
|
||||
'';
|
||||
in
|
||||
{
|
||||
sops.secrets = {
|
||||
"restic/repo_url" = { };
|
||||
"restic/repo_password" = { };
|
||||
};
|
||||
|
||||
custom.restic = {
|
||||
enable = true;
|
||||
paths = [
|
||||
"/backup/db"
|
||||
"/backup/var/lib"
|
||||
];
|
||||
backupPrepareCommand = [
|
||||
''
|
||||
mkdir -p /backup/var
|
||||
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r /var/lib /backup/var/lib
|
||||
''
|
||||
];
|
||||
backupCleanupCommand = [
|
||||
''
|
||||
${pkgs.btrfs-progs}/bin/btrfs subvolume delete /backup/var/lib
|
||||
''
|
||||
];
|
||||
btrfsRoots = [ ];
|
||||
};
|
||||
|
||||
services.postgresqlBackup = {
|
||||
enable = true;
|
||||
compression = "zstd";
|
||||
compressionLevel = 9;
|
||||
location = "/backup/db/postgresql";
|
||||
};
|
||||
|
||||
services.restic.backups.${config.networking.hostName} = {
|
||||
extraBackupArgs = [
|
||||
"--limit-upload=1024"
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue