Skip to content

fix(backup): '&&' line-leading in folded YAML crashed the backup service - #439

Merged
CheeryProgrammer merged 1 commit into
mainfrom
fix/backup-service-yaml
Jul 21, 2026
Merged

fix(backup): '&&' line-leading in folded YAML crashed the backup service#439
CheeryProgrammer merged 1 commit into
mainfrom
fix/backup-service-yaml

Conversation

@CheeryProgrammer

Copy link
Copy Markdown
Contributor

Problem

The backup service (profiles: ["backup"]) crash-loops and writes zero backups — backups/ stays empty.

Its entrypoint is a > folded scalar, but the inner lines are indented deeper than while true; do, so YAML preserves their newlines instead of folding them to spaces. That leaves && at the start of a line, so /bin/sh reports Syntax error: "&&" unexpected and the container restart-loops. No automated DB backups are taken (data-safety gap).

Fix

Move && to the end of the pg_dump line so it's a valid line continuation (… .sql.gz &&\n echo …), regardless of how YAML folds the block:

-  pg_dump … | gzip > /backups/brainiac-$$ts.sql.gz
-  && echo "backup: wrote brainiac-$$ts.sql.gz";
+  pg_dump … | gzip > /backups/brainiac-$$ts.sql.gz &&
+  echo "backup: wrote brainiac-$$ts.sql.gz";

Verification (real run)

docker compose --profile backup up -d backup:

  • Service stays Up (was Restarting).
  • Writes brainiac-<ts>.sql.gz (~160 KB); gzip -t passes; content starts -- PostgreSQL database dump.
  • Log: backup: wrote brainiac-<ts>.sql.gz — no && syntax error.

One-line compose change; no app/schema impact.


🤖 Generated with Claude Code

The backup service entrypoint is a ">" folded scalar, but its inner
lines are indented deeper than `while true; do`, so YAML preserves their
newlines instead of folding them to spaces. That put `&&` at the start
of a line, so /bin/sh got `Syntax error: "&&" unexpected` and the
container crash-looped — no DB backups were ever written (backups/ empty).

Move `&&` to the end of the pg_dump line so it reads as a valid line
continuation. Verified: the service now stays Up and writes a valid
gzipped pg_dump (`-- PostgreSQL database dump`) with `backup: wrote …`.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@CheeryProgrammer
CheeryProgrammer merged commit 4e38118 into main Jul 21, 2026
5 checks passed
@CheeryProgrammer
CheeryProgrammer deleted the fix/backup-service-yaml branch July 21, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant