Skip to content
Website

Backups & Upgrades

This guide is for operators managing backups, upgrades, and disaster recovery.

  • PostgreSQL (pg_dump): Nightly compressed custom-format dump (-Fc), plus a pre-upgrade snapshot.
  • MinIO data directory: Nightly incremental sync (rsync or robocopy) of /var/lib/minio/data (or ./.minio-data in development).
  • .env secrets: Back up .env securely (especially TOKEN_ENCRYPTION_KEY, SESSION_SECRET, and CSRF_SECRET).
Terminal window
pg_dump -Fc -U postgres patchwork > patchwork-$(Get-Date -Format yyyy-MM-dd).dump
# Restore:
pg_restore -d patchwork --clean --if-exists -U postgres patchwork-YYYY-MM-DD.dump
  1. Back up PostgreSQL and .env.
  2. Pull the new release and install dependencies:
    Terminal window
    npm ci
    npm run db:migrate
    npm run build
  3. Restart Patchwork (sudo systemctl restart patchwork.service on Linux, or npm run stop then npm run start).
  1. Provision PostgreSQL 16+ and restore your latest .dump with pg_restore.
  2. Restore the MinIO data directory before starting MinIO.
  3. Restore .env with restricted permissions (chmod 600 .env on Linux; icacls on Windows).
  4. Run node scripts/setup.mjs --check and verify /api/health.

In Easy mode, all persistent state lives in .env, ./data/postgres/, and ./data/minio/:

  1. While Patchwork is running (npm run start), dump PostgreSQL using the bundled pg_dump (or psql) from node_modules/@embedded-postgres/*/native/bin/pg_dump against DATABASE_URL in .env.
  2. Stop the stack (npm run stop) and copy ./data/minio/ and .env to a safe backup directory.
  3. Running npm run setup -- --action=reset also offers an automatic pg_dump + ./data/minio backup into ./backups/ before wiping data.
  1. Dump the Easy-mode database while running: pg_dump "<easy-DATABASE_URL>" > patchwork-backup.sql
  2. Stop the Easy-mode supervisor (npm run stop).
  3. Provision your external PostgreSQL 16+ database and restore: psql "<advanced-DATABASE_URL>" < patchwork-backup.sql
  4. Copy ./data/minio/ to your external MinIO data directory (or point your external MinIO server at the copied directory).
  5. Update .env (PATCHWORK_INSTALL_MODE=advanced, DATABASE_URL, S3_ENDPOINT, MINIO_PUBLIC_URL, S3_ACCESS_KEY, S3_SECRET_KEY), then start with npm run start.