Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(scripts): keep an in-container backup's staging off the tmpfs
Yudhi Armyndharisd8811fec012e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b1fc0882a..9963c5f0b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -119,7 +119,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Ingress manifests with an ack header value Node cannot send, a non-final ack status, a non-numeric `toleranceSec`, or a route that cannot travel as one URL path segment are refused at load, and minted ingress URLs percent-encode the route.- `GET` and `DELETE /mcp` answer `405` instead of `404`, so Streamable HTTP clients stop reporting an SSE error on connect.- A mixed-case or padded `POSTGRES_SCHEMA` is refused at boot, by the init script, by the migration CLI and on the Infrastructure page, instead of splitting the tables across two schemas.-- `backup.sh` fails before staging anything when `BACKUP_DIR` is not writable, such as the default on the container's read-only root.+- `backup.sh` fails before staging anything when `BACKUP_DIR` is not writable, such as the default on the container's read-only root, and names the `BACKUP_DIR` to use inside the container, plus the `TMPDIR` under docker compose, whose `/tmp` is memory-backed.- Dashboard: the multi-group send refuses an empty message or a missing media source and stops on a `409` instead of repeating the failure for every group.- Dashboard: the Message Tester follows a selected session that drops out of the ready list instead of sending to it.- Dashboard: a bulk send no longer starts polling its progress after the page is left.diff --git a/docs/11-operational-runbooks.md b/docs/11-operational-runbooks.mdindex 02aa2c329..089117a2e 100644--- a/docs/11-operational-runbooks.md+++ b/docs/11-operational-runbooks.md@@ -596,12 +596,19 @@ OPENWA_DATA_DIR=/srv/openwa/data \> volume as the data does not survive losing that volume:>> ```bash-> docker exec -e BACKUP_DIR=/app/data/backups openwa-api ./scripts/backup.sh+> docker exec -e BACKUP_DIR=/app/data/backups -e TMPDIR=/app/data/backups openwa-api ./scripts/backup.sh> docker cp openwa-api:/app/data/backups/. ./backups/> # Helm: kubectl exec <pod> -- env BACKUP_DIR=/app/data/backups ./scripts/backup.sh> # kubectl cp <pod>:/app/data/backups ./backups> ```>+> The script stages a full copy of the data in `TMPDIR` before archiving it. The compose file mounts+> `/tmp` as a tmpfs charged to the container's memory limit, so the compose line points `TMPDIR` at+> the data volume, which then needs free space for about the size of the data plus the archive;+> staging in the tmpfs gets the running gateway OOM-killed. The Helm chart's `/tmp` is an `emptyDir`+> on node disk, so the Helm lines leave it alone. A run killed outright, such as by a container+> restart mid-backup, leaves its `tmp.*` staging directory behind in `TMPDIR`; delete it.+>> The scripts resolve every other path the way the application does: an explicit environment value> first, then `./.env`, then `<data dir>/.env.generated`. Settings made through Dashboard >> Infrastructure therefore apply without being restated on the command line. Two caveats whendiff --git a/scripts/backup.sh b/scripts/backup.shindex 06cb621ae..5c836b047 100755--- a/scripts/backup.sh+++ b/scripts/backup.sh@@ -79,12 +79,15 @@ log() { echo "[backup] $*"; }# Check the destination before staging anything. The shipped container's root filesystem is# read-only, so the default ./backups (/app/backups) cannot be created there; failing only at the-# end would first copy every database, session and media file into the memory-backed /tmp.+# end would first copy every database, session and media file into the staging directory.if ! mkdir -p "$BACKUP_DIR" 2>/dev/null || [ ! -w "$BACKUP_DIR" ]; then- log "ERROR: BACKUP_DIR=$BACKUP_DIR is not writable; point BACKUP_DIR at a writable, persistent directory (inside the read-only container use BACKUP_DIR=/app/data/backups)"+ log "ERROR: BACKUP_DIR=$BACKUP_DIR is not writable; point BACKUP_DIR at a writable, persistent directory (inside the container use BACKUP_DIR=/app/data/backups, and under docker compose also TMPDIR=/app/data/backups: its /tmp is a tmpfs charged to the container's memory)"exit 1fi+# The staging copy goes to TMPDIR. Under docker compose that is a tmpfs charged to the container's+# memory limit, so an in-container run there points TMPDIR at the data volume (docs/11); staging the+# data in the tmpfs gets the running gateway OOM-killed once the data outgrows its headroom.STAGE="$(mktemp -d)"trap 'rm -rf "$STAGE"' EXIT