diff --git a/consul_backup/metadata.json b/consul_backup/metadata.json index 8c880f2..44378bb 100644 --- a/consul_backup/metadata.json +++ b/consul_backup/metadata.json @@ -1,5 +1,5 @@ { - "backup_timestamp": "2025-11-26T02:00:46.427516", + "backup_timestamp": "2025-11-27T02:00:45.033278", "total_keys": 79, "successful_backups": 74, "failed_backups": 5, diff --git a/consul_backup/nomad/postgres/members/pg-odroid6 b/consul_backup/nomad/postgres/members/pg-odroid6 index f3c603f..c0d1789 100644 --- a/consul_backup/nomad/postgres/members/pg-odroid6 +++ b/consul_backup/nomad/postgres/members/pg-odroid6 @@ -1 +1 @@ -{"conn_url":"postgres://192.168.4.226:5432/postgres","api_url":"http://192.168.4.226:8008/patroni","state":"running","role":"replica","version":"4.0.4","xlog_location":590757289528,"replication_state":"streaming","timeline":248} \ No newline at end of file +{"conn_url":"postgres://192.168.4.226:5432/postgres","api_url":"http://192.168.4.226:8008/patroni","state":"running","role":"replica","version":"4.0.4","xlog_location":591801262376,"replication_state":"streaming","timeline":248} \ No newline at end of file diff --git a/consul_backup/nomad/postgres/members/pg-odroid7 b/consul_backup/nomad/postgres/members/pg-odroid7 index 9df243e..6a3a57a 100644 --- a/consul_backup/nomad/postgres/members/pg-odroid7 +++ b/consul_backup/nomad/postgres/members/pg-odroid7 @@ -1 +1 @@ -{"conn_url":"postgres://192.168.4.227:5432/postgres","api_url":"http://192.168.4.227:8008/patroni","state":"running","role":"replica","version":"4.0.4","xlog_location":590757274112,"replication_state":"streaming","timeline":248} \ No newline at end of file +{"conn_url":"postgres://192.168.4.227:5432/postgres","api_url":"http://192.168.4.227:8008/patroni","state":"running","role":"replica","version":"4.0.4","xlog_location":591801239752,"replication_state":"streaming","timeline":248} \ No newline at end of file diff --git a/consul_backup/nomad/postgres/members/pg-odroid8 b/consul_backup/nomad/postgres/members/pg-odroid8 index 58f77b1..c9f181f 100644 --- a/consul_backup/nomad/postgres/members/pg-odroid8 +++ b/consul_backup/nomad/postgres/members/pg-odroid8 @@ -1 +1 @@ -{"conn_url":"postgres://192.168.4.228:5432/postgres","api_url":"http://192.168.4.228:8008/patroni","state":"running","role":"primary","version":"4.0.4","xlog_location":590757273600,"timeline":248} \ No newline at end of file +{"conn_url":"postgres://192.168.4.228:5432/postgres","api_url":"http://192.168.4.228:8008/patroni","state":"running","role":"primary","version":"4.0.4","xlog_location":591801239752,"timeline":248} \ No newline at end of file diff --git a/consul_backup/nomad/postgres/members/pg-opti1 b/consul_backup/nomad/postgres/members/pg-opti1 index c4541b6..6ce5577 100644 --- a/consul_backup/nomad/postgres/members/pg-opti1 +++ b/consul_backup/nomad/postgres/members/pg-opti1 @@ -1 +1 @@ -{"conn_url":"postgres://192.168.4.36:5432/postgres","api_url":"http://192.168.4.36:8008/patroni","state":"running","role":"replica","version":"4.0.4","xlog_location":590757297544,"replication_state":"streaming","timeline":248} \ No newline at end of file +{"conn_url":"postgres://192.168.4.36:5432/postgres","api_url":"http://192.168.4.36:8008/patroni","state":"running","role":"replica","version":"4.0.4","xlog_location":591801281992,"replication_state":"streaming","timeline":248} \ No newline at end of file diff --git a/consul_backup/nomad/postgres/status b/consul_backup/nomad/postgres/status index 7a0adeb..588070b 100644 --- a/consul_backup/nomad/postgres/status +++ b/consul_backup/nomad/postgres/status @@ -1 +1 @@ -{"optime":590757346904,"slots":{"pg_odroid6":590757346904,"pg_odroid7":590757346904,"pg_opti1":590757346904,"pg_odroid8":590757346904},"retain_slots":["pg_odroid6","pg_odroid7","pg_odroid8","pg_opti1"]} \ No newline at end of file +{"optime":591801239752,"slots":{"pg_odroid6":591801239752,"pg_odroid7":591801239752,"pg_opti1":591801239752,"pg_odroid8":591801239752},"retain_slots":["pg_odroid6","pg_odroid7","pg_odroid8","pg_opti1"]} \ No newline at end of file diff --git a/nomad_backup/trilium.hcl b/nomad_backup/trilium.hcl index 1399019..5530df8 100644 --- a/nomad_backup/trilium.hcl +++ b/nomad_backup/trilium.hcl @@ -2,6 +2,12 @@ job "trilium" { datacenters = ["dc1"] type = "service" + constraint { + attribute = "${node.unique.name}" + value = "odroid7" + } + + group "trilium" { count = 1 @@ -38,7 +44,7 @@ job "trilium" { ports = ["http"] volumes = [ "/mnt/configs/trilium:/home/node/trilium-data/data", - "/mnt/Public/configs/trilium/backup:/home/node/trilium-data/backup", + "/mnt/Public/configs/trilium/backup:/home/node/backup", "/mnt/Public/configs/trilium/config:/home/node/trilium-data/config" @@ -46,8 +52,8 @@ job "trilium" { } env { TRILIUM_DATA_DIR="/home/node/trilium-data/data" - TRILIUM_BACKUP_DIR="/home/node/trilium-data/backup" - TRILIUM_CONFIG_INI_PATH= "/home/node/trilium-data/config/config.ini" + TRILIUM_BACKUP_DIRxx="/home/node/backup" + TRILIUM_CONFIG_INI_PATH="/home/node/trilium-data/config/config.ini" } resources { @@ -75,6 +81,46 @@ job "trilium" { } } + +#inside group "trilium" ...rsync sidecar to copy trilium native backup to public + + task "rsync-sidecar" { + driver = "docker" + + lifecycle { + hook = "poststart" + sidecar = true + } + + config { + image = "alpine:latest" + command = "/bin/sh" + memory_hard_limit = "2048" + args = [ + "-c", + # 1. Install rsync + # 2. Enter infinite loop + # 3. Rsync data -> backup + # 4. Sleep 30 mins (1800 seconds) + "apk add --no-cache rsync && while true; do echo '[Sidecar] Starting rsync...'; rsync -av --delete /data/ /backup/; echo '[Sidecar] Done. Sleeping 30m...'; sleep 1800; done" + ] + + # Ensure these match the paths you want to sync + volumes = [ + "/mnt/configs/trilium:/data", # Source + "/mnt/Public/configs/trilium/backup:/backup" # Destination + ] + } + + resources { + cpu = 50 + memory = 50 + } + } + + + + # Litestream sidecar for continuous replication task "litestream" { driver = "docker" @@ -86,7 +132,7 @@ job "trilium" { image = "litestream/litestream:latest" args = [ "replicate", - "/alloc/tmp/trilium.db", + "/data/document.db", "sftp://root:odroid@192.168.4.63/mnt/Shares/litestream/trilium.db" ] volumes = [