WFDASH-WEBAPP/scripts/pb-hooks
…
..
README.md
sync-pb-hooks.sh

PocketBase hooks sync (WFDASH)

The live WFDASH PocketBase (Coolify service pocketbase-wfdash, container pocketbase-gnqc88suy8fqk6wyryjjdpvl, PocketBase 0.39.8) loads its hooks from the Docker volume gnqc88suy8fqk6wyryjjdpvl_pocketbase-hooks, mounted at /app/pb_hooks.

Hooks are deployed from git, not edited on the server:

  1. Edit or add files in pocketbase/pb_hooks/ in this repo (the source of truth).
  2. List every file to deploy in pocketbase/pb_hooks/DEPLOY.
  3. Commit, then publish the folder to the hooks repo: npm run pb:hooks:publish (pushes pocketbase/pb_hooks to main of Forgejo David/WFDASH-PBHOOKS with git subtree).

Within ~2 minutes the VPS cron runs /opt/wfdash-pb-hooks/sync-pb-hooks.sh, which pulls WFDASH-PBHOOKS into /opt/wfdash-pb-hooks/repo and copies the listed files into the volume. PocketBase reloads itself when a hook file changes. A .js file on the server that isn't in DEPLOY is removed.

  • Log: /var/log/wfdash-pb-hooks-sync.log on the VPS.
  • Force a sync: /opt/wfdash-pb-hooks/sync-pb-hooks.sh --force
  • Roll back: revert the commit (or remove the line from DEPLOY), commit, npm run pb:hooks:publish.
  • Pause syncing: comment out the cron line (crontab -e as root).
  • The script itself is installed by copying this file to the VPS; re-copy it after changing it.

The sync never touches pb_data (the database).