Legacy Wiki.js local dev and prod sync (buckyverse.org)
Legacy notes for the old Wiki.js deployment, kept for reference after the wiki migration to llm-wiki/.
Why
- Production sync is slow — editing and syncing on the droplet can be slow and fragile.
- Local mirror — pull the prod DB (and optionally wiki data) once, work locally at full speed.
- Controlled push — when ready, push DB (and optionally data) back to DigitalOcean.
Architecture
- Local: Docker Compose in
dev/wikijs/: Wiki.js 2 + PostgreSQL. Data in Docker volumesbuckyverse-wikijs-db-dataandbuckyverse-wikijs-data. - Production: Wiki.js on a DigitalOcean droplet, run with Docker Compose (PostgreSQL + wiki service).
- Sync: Scripts use SSH to run
pg_dumpon prod and restore locally (pull), or the reverse (push). Optional: sync the wiki data volume with--data.
Production setup (from inspect)
As of the last inspect-prod.sh run:
| Item | Production |
|---|---|
| Host | r26d@buckyverse.org |
| Containers | wiki (ghcr.io/requarks/wiki:2), db (postgres:11), wiki-update-companion |
| Compose | docker-compose v1.29 (use docker-compose not docker compose on server) |
| Postgres user | wiki (not wikijs) |
| Postgres volume | pgdata |
| Wiki content volume | Anonymous volume e061d18871d73252bbef2d76f92ecd83933c39c7b99aca43a48bfb8431059fec → mounted at /wiki/data/content in container |
| Ports | Wiki.js on 80 (→3000), 443 (→3443) |
PROD_COMPOSE_DIR is optional. Pull and push use docker exec by container name (db, wiki), so they work without it. If you set PROD_COMPOSE_DIR, you can use push-to-prod.sh --switch to have the script point Wiki.js at the new DB automatically. (The stack may have been started by root from e.g. /etc/wiki or /root/wiki; r26d often cannot read those paths.)
Related
- Synergetics Dictionary: Content is synced from the elib-synergetics-dictionary repo via GraphQL; see that doc for the sync script and options.
- Sync to another dev machine: To copy the Wiki.js DB to a second dev environment on the same network, see wikijs-sync-to-other-dev.md.
- Change favicon on the droplet: Wiki.js has no admin setting for favicon; see wikijs-favicon-droplet.md for mounting custom favicons in Docker on production.
Prerequisites
- Docker and Docker Compose on your machine.
- SSH access as
r26d@buckyverse.org(see ssh-keys-audit.md if needed). - On the droplet: Wiki.js run via Docker Compose with services
db(PostgreSQL) andwiki.
One-time setup
-
Clone/navigate to repo
cd /path/to/buckyverse.org -
Configure local env
cd dev/wikijs cp .env.example .envEdit
.env:- PROD_SSH (required):
r26d@buckyverse.org. - PROD_DB_USER:
wiki(production Postgres user; local useswikijs). - PROD_SSH_KEY (optional): path to SSH key if not default (e.g.
~/.ssh/id_rsa_r26d_2048). - PROD_WIKI_VOLUME (optional): only for
--datasync; use volume IDe061d18871d73252bbef2d76f92ecd83933c39c7b99aca43a48bfb8431059fec.
PROD_COMPOSE_DIR (optional): set if you wantpush-to-prod.sh --switchto update the prod Wiki.js DB and recreate the container from your machine.
- PROD_SSH (required):
-
Start local stack
docker compose up -dOpen http://localhost:3000 and complete the initial Wiki.js wizard once (this will be overwritten when you pull from prod).
-
Pull production
chmod +x scripts/pull-from-prod.sh scripts/push-to-prod.sh ./scripts/pull-from-prod.shThis dumps the prod PostgreSQL DB, restores it locally, and restarts the local wiki. Reload http://localhost:3000 — you should see production content.
Daily workflow
-
Refresh from prod (optional)
To get latest production state:cd dev/wikijs ./scripts/pull-from-prod.sh -
Edit locally
Use http://localhost:3000. No dependency on production sync speed. -
Push to production
When ready to publish:./scripts/push-to-prod.shThe script creates a new database on prod (e.g.
wiki_20260217_143022), restores your local dump into it, and leaves the current prod DB unchanged. You then point Wiki.js at the new DB; if anything goes wrong, rollback is instant by pointing back. See wikijs-push-rollback.md for switch and rollback steps.
Syncing the wiki data volume (optional)
Wiki.js stores uploads and cache in a data volume. If you need that mirrored:
- Find prod volume name on the droplet:
docker volume ls(oftenwikijs_wiki-dataor<compose_project>_wiki-data). - Set in
.env:PROD_WIKI_VOLUME=that_volume_name. - Pull including data:
./scripts/pull-from-prod.sh --data - Push including data:
./scripts/push-to-prod.sh --data
Use --data only when you need uploads/cache in sync; DB-only is usually enough for content.
Production compose path
If Wiki.js on the droplet is not in /root/wikijs, set in .env:
PROD_COMPOSE_DIR=/opt/wikijs
Scripts run docker compose in that directory on the remote host.
Excluding large tables from pull
The assetData table (Wiki.js asset blobs) can be large and cause the connection to drop during pg_dump. The pull script excludes that table’s data by default (schema is still dumped). Your local wiki will have the table but no asset rows; page content and structure are unchanged. To include it (and risk the same failure), set in .env:
PROD_DUMP_EXCLUDE_TABLE_DATA=
To include assetData in the dump (may fail if the table is large), set PROD_DUMP_EXCLUDE_TABLE_DATA= (empty) in .env. Default is "public"."assetData".
Troubleshooting
- “Set PROD_SSH in .env” — create
.envfrom.env.exampleand setPROD_SSH. - SSH connection refused / timeout — check droplet IP, firewall (port 22), and SSH key.
- Permission denied (publickey) — use
PROD_SSH_KEYin.envorssh -i <key> $PROD_SSHto test. - No such service “db” / “wiki” — confirm prod runs Docker Compose with services named
dbandwiki; adjust prod or script if your names differ. - Restore fails locally — ensure local stack is up (
docker compose up -d), then run pull again. If the prod DB is very large, dump/restore may take a few minutes. - Prod slow after push — first load after DB restore can be heavy; give it a minute. If you use
--data, ensure the droplet has enough disk and memory.
Files reference
| Path | Purpose |
|---|---|
dev/wikijs/docker-compose.yml |
Local Wiki.js + PostgreSQL. |
dev/wikijs/.env.example |
Template for .env (copy to .env). |
dev/wikijs/scripts/pull-from-prod.sh |
Pull DB (and optionally data) from droplet. |
dev/wikijs/scripts/push-to-prod.sh |
Push DB to a new prod DB (and optionally data); see wikijs-push-rollback.md. |
dev/wikijs/scripts/dump-for-sync.sh |
Create a DB dump for syncing to another dev machine; see wikijs-sync-to-other-dev.md. |
dev/wikijs/scripts/restore-from-backup.sh |
Restore local DB from a dump (e.g. after copying from another dev). |
dev/wikijs/backups/ |
DB dumps and optional data tarballs (gitignored). |
Security notes
- Do not commit
.env(it’s indev/wikijs/.gitignore). - Prefer SSH keys over passwords for
PROD_SSH. - Backups in
dev/wikijs/backups/may contain sensitive wiki content; keep that directory local and out of version control.