diff --git a/base.nix b/base.nix index 5cc03ba..4978d41 100755 --- a/base.nix +++ b/base.nix @@ -4,6 +4,7 @@ let syncs = [ "nas" "dns" + "linode" ]; in { @@ -44,6 +45,12 @@ in ]; id = "C4XJCH7-3ZNW6XZ-R5DB2EU-OEGVVT2-WPHQAG7-UDWER36-6NO5KZR-4MN5VAK"; }; + linode = { + addresses = [ + "tcp://linode.thehellings.com:22000" + ]; + id = "3PHWAI5-ILAWGGD-S5FC5QM-M2WQ2FX-PZ3IXQF-QVRKANG-WXAACJC-2MZN3Q5"; + }; }; folders = { "mkrvy-tc6x9" = { diff --git a/hosts/linode/default.nix b/hosts/linode/default.nix index 38ab82e..3f9f0da 100644 --- a/hosts/linode/default.nix +++ b/hosts/linode/default.nix @@ -3,6 +3,7 @@ { imports = [ ../../profiles/linode.nix + ./postgres.nix ]; - networking.hostName = "linode"; + networking.hostName = "linode"; } diff --git a/hosts/linode/postgres.nix b/hosts/linode/postgres.nix new file mode 100644 index 0000000..e823ffd --- /dev/null +++ b/hosts/linode/postgres.nix @@ -0,0 +1,42 @@ +{ config, ... }: + +{ + services.postgresql = { + enable = true; + checkConfig = true; + ensureDatabases = [ "synapse" "nextcloud" ]; + ensureUsers = [ { + name = "synapse"; + ensurePermissions."DATABASE synapse" = "ALL PRIVILEGES"; + } { + name = "root"; + ensurePermissions."ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES"; + } ]; + settings = { + log_connections = true; + log_statement = "all"; + logging_collector = true; + }; + identMap = '' +root root root +''; + }; + + services.postgresqlBackup.enable = true; + + services.logrotate = { + enable = true; + paths = { + postgres = { + enable = true; + path = "${config.services.postgresqlBackup.location}/*.gz"; + }; + }; + }; + + services.syncthing.folders."postgres-backups" = { + path = "${config.services.postgresqlBackup.location}"; + enable = true; + devices = [ "nas" ]; + }; +}