diff options
Diffstat (limited to 'os/srv/backup.nix')
| -rw-r--r-- | os/srv/backup.nix | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/os/srv/backup.nix b/os/srv/backup.nix deleted file mode 100644 index e7c07f9..0000000 --- a/os/srv/backup.nix +++ /dev/null @@ -1,97 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -let - cfg = config.os.srv.replication; - pgLockScript = pkgs.writeScriptBin "pg-lock" '' - #!/bin/sh - microvm -s database-vm -- sudo -u postgres psql -c "SELECT pg_backup_start('sanoid_snap');" - ''; - - pgUnlockScript = pkgs.writeScriptBin "pg-unlock" '' - #!/bin/sh - microvm -s database-vm -- sudo -u postgres psql -c "SELECT pg_backup_stop();" - ''; -in -{ - options.os.srv.replication.enable = lib.mkEnableOption "enables replications"; - config = lib.mkIf cfg.enable { - services = { - sanoid = { - enable = true; - templates.production = { - autosnap = true; - autoprune = true; - hourly = 24; - daily = 7; - weekly = 4; - monthly = 3; - }; - datasets = { - "zroot/rpool/appdata/db/postgres" = { - useTemplate = [ "production" ]; - - pre_snapshot_script = "${pgLockScript}/bin/pg-lock"; - post_snapshot_script = "${pgUnlockScript}/bin/pg-unlock"; - no_inconsistent_snapshot = true; - force_post_snapshot_script = true; - script_timeout = 30; - }; - - "zroot/rpool/appdata/db/redis".useTemplate = [ "production" ]; - - "zroot/rpool/appdata/db/couchdb".useTemplate = [ "production" ]; - - "zroot/rpool/appdata/cfg".useTemplate = [ "production" ]; - - "zroot/rpool/appdata/games".useTemplate = [ "production" ]; - - "zroot/rpool/appdata/mail".useTemplate = [ "production" ]; - - "zroot/rpool/containers".useTemplate = [ "production" ]; - }; - }; - - syncoid = { - enable = true; - commonArgs = [ - "-c" - "-p" - "--delete-target-snapshots" - "--use-hold" - "--no-sync-snap" - ]; - commands = { - "sync-databases" = { - source = "zroot/rpool/appdata/db"; - target = "tank/ztank/backup/nvme/db"; - recursive = true; - }; - - "sync-config" = { - source = "zroot/rpool/appdata/cfg"; - target = "tank/ztank/backup/nvme/cfg"; - }; - - "sync-games" = { - source = "zroot/rpool/appdata/games"; - target = "tank/ztank/backup/nvme/games"; - }; - - "sync-mail" = { - source = "zroot/rpool/appdata/mail"; - target = "tank/ztank/backup/nvme/mail"; - }; - - "sync-docker" = { - source = "zroot/rpool/containers"; - target = "tank/ztank/backup/nvme/containers"; - }; - }; - }; - }; - }; -} |
