mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-12-07 13:32:15 -06:00
69 lines
1.4 KiB
Nix
Executable file
69 lines
1.4 KiB
Nix
Executable file
{ flake, ... }:
|
|
let
|
|
inherit (flake.config.machines.devices)
|
|
ceres
|
|
;
|
|
inherit (flake.config.services)
|
|
instances
|
|
;
|
|
|
|
service = instances.postgresql;
|
|
backupPath = "${instances.syncthing.paths.path0}/postgres-backups";
|
|
in
|
|
{
|
|
services = {
|
|
postgresqlBackup = {
|
|
enable = true;
|
|
location = backupPath;
|
|
compression = "zstd";
|
|
startAt = "*-*-* 07:00:00";
|
|
databases = [
|
|
instances.mastodon.name
|
|
instances.forgejo.name
|
|
instances.firefly-iii.name
|
|
];
|
|
};
|
|
postgresql = {
|
|
enable = true;
|
|
# ensureDatabases = [ firefly-iii.name ];
|
|
# ensureUsers = [
|
|
# {
|
|
# name = firefly-iii.name;
|
|
# ensureDBOwnership = true;
|
|
# }
|
|
# ];
|
|
};
|
|
};
|
|
networking = {
|
|
firewall = {
|
|
allowedTCPPorts = [
|
|
service.ports.port0
|
|
];
|
|
};
|
|
};
|
|
|
|
fileSystems."/var/lib/postgresql" = {
|
|
device = service.paths.path0;
|
|
fsType = "none";
|
|
options = [
|
|
"bind"
|
|
];
|
|
depends = [
|
|
ceres.storage0.mount
|
|
];
|
|
};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"d ${backupPath} 0750 ${service.name} ${instances.syncthing.name} -"
|
|
];
|
|
|
|
users.users.${service.name}.extraGroups = [
|
|
instances.nextcloud.name
|
|
instances.mastodon.name
|
|
instances.forgejo.name
|
|
];
|
|
|
|
system.activationScripts.postgresCommands = ''
|
|
chown -R ${service.name}:${service.name} ${service.paths.path0}
|
|
'';
|
|
}
|