From 888fa2f6b503b9ca9bf35bd862e7f8fde1d296e8 Mon Sep 17 00:00:00 2001 From: Jennie Robinson Faber Date: Wed, 8 Apr 2026 11:57:02 +0100 Subject: [PATCH] Fix two cron jobs that surfaced once the container could actually run them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With yesterday's cron infrastructure fix in place, both daily jobs got to actually execute today and revealed bugs that had been hiding behind the silent failures. 1. Wiki export crashed on docs whose body starts with `---` (markdown horizontal rule). matter.stringify(str, data) re-parses str as if it might already contain frontmatter, so a leading `---` makes gray-matter try to YAML-parse the body and choke on the first `Title: subtitle` colon. Pass {content: str} instead — the parser only runs on bare strings, so an object skips the re-parse path. 2. outline-backup.sh referenced docker container names `outline-postgres` and `outline`, but DokPloy names containers `${project}-${service}-1`, so the backup got `Error response from daemon: No such container`. Derive names from $APP_NAME (set to the compose project name) with POSTGRES_CONTAINER / OUTLINE_CONTAINER overrides for portability. --- scripts/export-content.js | 6 +++++- scripts/outline-backup.sh | 15 +++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/export-content.js b/scripts/export-content.js index 29c1d29..40442ce 100755 --- a/scripts/export-content.js +++ b/scripts/export-content.js @@ -156,7 +156,11 @@ async function main() { createdBy: doc.createdBy?.email || doc.createdBy?.name || null, }; - const content = matter.stringify(doc.text || "", frontmatter); + // Pass an object (not a bare string) so gray-matter doesn't run the body + // through its frontmatter parser. Otherwise an Outline doc whose body + // starts with `---` (markdown horizontal rule) gets misread as having + // YAML frontmatter and crashes the export. + const content = matter.stringify({ content: doc.text || "" }, frontmatter); const filePath = path.join(OUTPUT_DIR, filename); await fs.writeFile(filePath, content, "utf-8"); diff --git a/scripts/outline-backup.sh b/scripts/outline-backup.sh index a161d5e..5dc3423 100755 --- a/scripts/outline-backup.sh +++ b/scripts/outline-backup.sh @@ -16,19 +16,26 @@ BACKUP_DIR="${1:-/backups/outline}" DATE=$(date +%Y-%m-%d_%H%M) RETENTION_DAYS=14 +# DokPloy names containers ${COMPOSE_PROJECT}-${SERVICE}-1. APP_NAME is set +# to the compose project name in the .env file, so derive the container +# names from that. Allow overrides via env vars for portability. +PROJECT="${APP_NAME:-outline}" +POSTGRES_CONTAINER="${POSTGRES_CONTAINER:-${PROJECT}-postgres-1}" +OUTLINE_CONTAINER="${OUTLINE_CONTAINER:-${PROJECT}-outline-1}" + mkdir -p "$BACKUP_DIR" echo "=== Outline Backup — $DATE ===" # PostgreSQL dump -echo "Backing up PostgreSQL..." -docker exec outline-postgres pg_dump -U outline -Fc outline \ +echo "Backing up PostgreSQL from $POSTGRES_CONTAINER..." +docker exec "$POSTGRES_CONTAINER" pg_dump -U outline -Fc outline \ > "$BACKUP_DIR/outline-db-$DATE.dump" echo " Database: outline-db-$DATE.dump" # File storage backup -echo "Backing up file storage..." -docker cp outline:/var/lib/outline/data - \ +echo "Backing up file storage from $OUTLINE_CONTAINER..." +docker cp "$OUTLINE_CONTAINER:/var/lib/outline/data" - \ | gzip > "$BACKUP_DIR/outline-files-$DATE.tar.gz" echo " Files: outline-files-$DATE.tar.gz"