Skip to content

Tutorial

This tutorial builds a small app on a local burrowDB cluster: a posts collection, a record, the dashboard, realtime in the browser, a hook, a failed replica, a scale-out and a backup. It takes about ten minutes. The video shows the same steps in two minutes.

You need Docker with Compose and the burrow CLI (Quick start). Work in an empty folder; the commands below call it my-app.

1. Start a cluster

burrow up local

This starts PostgreSQL, a pgbouncer connection pool, MinIO for files, two API replicas, a cron worker and an nginx edge on http://127.0.0.1:8090. The Compose project and its generated secrets live in ~/.burrow/stacks/local. When every service is healthy, burrow up prints where things are:

{
  "dashboard": "http://127.0.0.1:8090/_/",
  "replicas": 2,
  "stackDir": "/Users/you/.burrow/stacks/local",
  "superuser": "admin@burrow.local",
  "url": "http://127.0.0.1:8090"
}

2. Sign in

The superuser's password is in the stack's .env file. Pipe it to burrow login, which stores the token in ~/.burrow/credentials.json so later commands are signed in:

grep BURROW_SUPERUSER_PASSWORD ~/.burrow/stacks/local/.env | cut -d= -f2- \
  | burrow login --email admin@burrow.local --password-stdin

3. Create a collection

Collections are the same JSON the PocketBase dashboard exports. Save this as posts.json: a posts collection with a required title and a slug, readable by anyone (listRule and viewRule are empty strings, which in PocketBase means public).

{
  "name": "posts",
  "type": "base",
  "listRule": "",
  "viewRule": "",
  "fields": [
    { "name": "title", "type": "text", "required": true },
    { "name": "slug",  "type": "text" }
  ]
}
burrow collections create posts.json

4. Add and list records

burrow records create posts '{"title":"Hello from burrowDB"}'
burrow records list posts --fields id,title,slug -o table
id               title                slug
eqzufi7taee601v  Hello from burrowDB

burrow records talks to PocketBase's records API, unchanged; filters, sorting and --fields work as in PocketBase.

5. Open the dashboard

Open http://127.0.0.1:8090/_/ and sign in with the same superuser.

The PocketBase superuser login of the local cluster

It is PocketBase's dashboard. Open posts to see the records:

The posts collection in the dashboard, with titles and slugs

Anything you change here (fields, rules, records, settings) is stored in PostgreSQL and seen by every replica.

6. Realtime from the SDK

Any PocketBase SDK works against the cluster. Save this as index.html and serve the folder (python3 -m http.server 8099), then open http://127.0.0.1:8099/:

<script src="https://cdn.jsdelivr.net/npm/pocketbase@0.26.2/dist/pocketbase.umd.js"></script>
<ol id="events"></ol>
<script>
  const pb = new PocketBase("http://127.0.0.1:8090");
  pb.collection("posts").subscribe("*", (e) => {
    const li = document.createElement("li");
    li.textContent = `${e.action}: ${e.record.title} (slug: ${e.record.slug || "none"})`;
    document.getElementById("events").prepend(li);
  });
</script>

Create a post in the terminal and it appears in the page:

burrow records create posts '{"title":"Realtime works"}'

The page's subscription is held by one API replica and the write may land on another. burrowDB passes the event between replicas through PostgreSQL, so every subscriber gets it. The screenshot shows two SDK clients, each with its own connection, receiving the same event:

Two PocketBase SDK clients both receive the new post

7. Add a hook

Hooks are PocketBase JavaScript (*.pb.js), unchanged. Save this as posts.pb.js; it gives every new post a slug made from its title:

// Give every new post a URL slug made from its title.
onRecordCreateRequest((e) => {
  const title = e.record.get("title")
  e.record.set("slug", title.toLowerCase().replace(/[^a-z0-9]+/g, "-"))
  e.next()
}, "posts")

Copy it into the stack's pb_hooks folder and restart the replicas, so every one of them loads it:

cp posts.pb.js ~/.burrow/stacks/local/pb_hooks/
docker compose -p burrowdb restart api worker
burrow records create posts '{"title":"Hooks run everywhere"}'
{
  "slug": "hooks-run-everywhere",
  "title": "Hooks run everywhere"
}

Every API replica runs the hook, so a hook must not assume it is the only process. Read Hooks at scale before writing hooks that send mail, call other services or keep state.

8. Lose a replica

Stop one replica on purpose, then write:

docker kill burrowdb-api-1
burrow records create posts '{"title":"Still up"}'

The write succeeds: the edge gives up on the dead replica within a second and sends the request to one that is alive. Realtime clients connected to the dead replica reconnect and resubscribe on their own (the SDK does this).

9. Scale out

Run burrow up again with more replicas. It keeps the database, the secrets and the running replicas, and adds the new one (it also starts the replica you killed):

burrow up local --replicas 3
docker ps --filter name=burrowdb-api --format '{{.Names}}  {{.Status}}'
burrowdb-api-3  Up 7 seconds (healthy)
burrowdb-api-2  Up 26 seconds (healthy)
burrowdb-api-1  Up 7 seconds (healthy)

10. Back up

A backup is a pg_dump of the databases plus the files, written to object storage (MinIO here):

burrow backups create
burrow backups list -o table
key                              size    modified
pb_backup_20261205041509.zip     255367  2026-12-05 04:15:10.086Z

burrow backups restore KEY loads a backup into a new database and swaps it in for the whole cluster. See Operations.

Clean up

burrow down local                   # stop; the data stays in Docker volumes
burrow down local --volumes --yes   # stop and delete the database and files

Next