Backup and upgrades
Back up Postgres and uploads, then upgrade ChatAI safely.
What to back up
| Data | Location | Notes |
|---|---|---|
| Database | Compose volume chatai_pgdata | Assistants, chunks, conversations, API keys |
| Uploads | Compose volume chatai_uploads | Original files under /app/uploads |
| Config | Your .env / secrets store | Not in the image |
Database dump
With Compose running:
docker compose exec -T db pg_dump -U chatai -d chatai -Fc > chatai-$(date +%Y%m%d).dumpPlain SQL:
docker compose exec -T db pg_dump -U chatai -d chatai > chatai-$(date +%Y%m%d).sqlRestore
# Example: custom format dump into a fresh volume
docker compose up -d db
docker compose exec -T db pg_restore -U chatai -d chatai --clean --if-exists < chatai-YYYYMMDD.dumpPrefer restoring into an empty database or a new volume. Coordinate with app downtime so ingest workers are not writing mid-restore.
Uploads volume
Copy the named volume or bind-mount contents. Example with a temporary Alpine container:
docker run --rm \
-v chatai-v07-self-hosting-docs_chatai_uploads:/data \
-v "$PWD:/backup" \
alpine tar czf /backup/chatai-uploads-$(date +%Y%m%d).tgz -C /data .Adjust the volume name to match docker volume ls on your host (Compose prefixes the project name).
Upgrade flow
-
Back up Postgres and uploads
-
Pull / rebuild the app image:
git pull docker compose build app -
Restart so the entrypoint runs migrations:
docker compose up -d appMigrations run automatically via
node /app/packages/database/scripts/migrate.mjson boot. You do not need to apply0000_*.sqlby hand. -
Smoke health:
curl -s http://localhost:3000/api/health # {"status":"ok","db":"ok"} -
Sign in, open an assistant playground, and send a short test message.
Existing databases
If an older install only applied the first SQL file and skipped later migrations, restarting the current image applies pending Drizzle migrations (0001–…) on boot.