AFFiNE said "Sync storage: 100 GB" and I wondered whose server I was on
A settings panel made me doubt my own self-hosted AFFiNE. What local-first sync actually means, what your domain does and doesn't prove, and the backup I still owe it.
765 KB used of 100 GB. That was the line in AFFiNE's account settings, under a heading about sync storage, and it made me stop. I had just spent an evening putting AFFiNE on my own VPS precisely so my notes would live on my own disk. Why was there a quota? Who had decided I get 100 GB? And what was "sync" syncing to?
I took a screenshot and asked the assistant I was building the stack with, more or less word for word: what does this sync mean, am I not self-hosting so that everything is on my server?
The short answer was yes, it's your server. The longer answer turned out to be more useful than the reassurance, because it separated two questions I'd mashed together: where does the data go, and who controls the place it goes. This post is that conversation, the stack behind it with every line explained, and the part I'd rather not admit, which is that the honest answer to "do I control my data" includes "and I haven't backed it up properly yet".
AFFiNE was one of two candidates I deployed that week as an open-source Notion replacement. AppFlowy was the other, and it took ten containers and a long night. AFFiNE took four containers and worked on the first start. That contrast is a big part of why AFFiNE is still in the running, so it's worth looking at how the stack is built before getting to the sync question.
The stack, annotated
The compose is adapted from the official self-host file in the AFFiNE repository. The first path the assistant tried for it returned 404. The API listing of the repository tree found the current one, under .docker/selfhost/compose.yml, next to a config.example.json. Paths like that move between releases, so if you're following an old guide, look in the repo tree rather than trusting a raw URL from a blog post. Including this one.
Upstream publishes port 3010 on the host and uses service names like postgres and redis. I removed the published port, because Traefik routes to the container over the shared frontend network, and renamed everything to my <app>_<role> convention. Here's the full file as it is in my repo, with the hostname sanitised and the timezone lines removed. The comments marked ## are added for this post. The rest are the file's own.
# AFFiNE. Needs .env — copy .env.example and fill it in.
# The first account to sign up becomes the instance admin: open the site right after
# the first start and register before anyone else does.
services:
app:
image: ghcr.io/toeverything/affine:stable ## not pinned yet, see "maintenance"
container_name: affine_app
restart: unless-stopped
networks: [frontend, internal] ## the only service Traefik can reach
environment:
- REDIS_SERVER_HOST=affine_redis
- DATABASE_URL=postgresql://affine:${AFFINE_DB_PASSWORD:?}@affine_db:5432/affine
- DEPLOYMENT_TYPE=selfhosted
## Traefik terminates TLS, so the container only ever sees plain HTTP.
## These two make AFFiNE build links and redirects for the public https URL.
- AFFINE_SERVER_EXTERNAL_URL=https://${AFFINE_HOST:-affine.example.com}
- AFFINE_SERVER_HTTPS=true
volumes:
- ./storage:/root/.affine/storage ## blobs and uploads: back this up
- ./config:/root/.affine/config ## instance config, git-ignored
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
migration:
condition: service_completed_successfully ## the app waits for the schema
labels:
- traefik.enable=true
- traefik.http.routers.affine.rule=Host(`${AFFINE_HOST:-affine.example.com}`)
- traefik.http.routers.affine.entrypoints=websecure
- traefik.http.routers.affine.middlewares=default-security-headers@file,remove_identity@file
- traefik.http.services.affine.loadbalancer.server.port=3010
- traefik.docker.network=frontend
# One-shot job: runs the DB migrations, then exits. Must finish before `app` starts.
migration:
image: ghcr.io/toeverything/affine:stable ## same image as the app, different command
container_name: affine_migration
restart: "no"
networks: [internal]
command: ["sh", "-c", "node ./scripts/self-host-predeploy.js"]
environment:
- REDIS_SERVER_HOST=affine_redis
- DATABASE_URL=postgresql://affine:${AFFINE_DB_PASSWORD:?}@affine_db:5432/affine
- DEPLOYMENT_TYPE=selfhosted
volumes:
- ./storage:/root/.affine/storage
- ./config:/root/.affine/config
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
db:
# pgvector is required (AI / semantic search features)
image: pgvector/pgvector:pg16
container_name: affine_db
restart: unless-stopped
networks: [internal]
environment:
- POSTGRES_USER=affine
- POSTGRES_PASSWORD=${AFFINE_DB_PASSWORD:?} ## read on first init ONLY
- POSTGRES_DB=affine
- POSTGRES_INITDB_ARGS=--data-checksums ## catches silent disk corruption early
volumes:
- ./db:/var/lib/postgresql/data ## the documents: back this up
healthcheck:
test: ["CMD", "pg_isready", "-U", "affine", "-d", "affine"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
container_name: affine_redis
restart: unless-stopped
networks: [internal] ## no volume: nothing here survives a recreate
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
frontend:
external: true
# Private to this stack. Deliberately NOT the shared `backend` network:
# several stacks have a service called `db`, and Docker DNS would resolve
# that name to a database from the wrong stack.
internal:
internal: trueAnd the whole .env.example:
AFFINE_HOST=affine.example.com
# openssl rand -hex 24 (hex only: it is embedded in a connection URL)
AFFINE_DB_PASSWORD=Two variables. Compare that with AppFlowy's twenty-odd and you have most of my opinion of the two stacks in one glance.
Why it looks like that
The migration job is my favourite part. It's the same image as the app, run once with a different command, and the app won't start until it has exited successfully. There's no race between "the schema is being created" and "the app wants the schema". I had exactly that race with AppFlowy's search service the same evening, and it cost me a crash loop and an extra commit. It also makes upgrades sane: every docker compose up -d after a new image runs the migrations first, then starts the app, so a schema change lands before the code that needs it.
AFFINE_SERVER_EXTERNAL_URL and AFFINE_SERVER_HTTPS=true exist because Traefik terminates TLS. From inside the container, every request arrives as plain HTTP from a proxy. Without these two, AFFiNE builds links, redirects and share URLs for the wrong scheme and host, and you get the classic reverse-proxy symptoms: login redirects to http://, mixed-content warnings, share links that point at a container name.
The database is pgvector/pgvector:pg16, not plain Postgres, because AFFiNE wants the vector extension for its AI and semantic search features. I don't use those, but the migrations expect the extension to exist. It's initialised with --data-checksums, which costs almost nothing and means Postgres will notice if the disk starts returning garbage instead of silently serving it.
Redis has no volume. As far as I can tell from how AFFiNE uses it, it's a cache and queue, not a store of record, so losing it on a recreate is fine. I haven't verified that against AFFiNE's docs, so treat it as my reading rather than a guarantee. If I'm wrong, I'll find out the first time I recreate it with something in flight.
Two conventions come from my other stacks, and both came from pain.
The password is hex only. A @, / or : in a password inside postgresql://user:pass@host is a URL-parsing bug waiting to happen, and a $ gets mangled by compose interpolation. Hex output from openssl rand has none of those problems.
The network is private to the stack and marked internal: true, so the database and Redis can't reach the outside world at all, and only the app joins the shared Traefik network. That comment in the file is a scar. When I first added a batch of stacks, they all shared one backend network and each had a service called db. Docker's DNS resolved db to whichever database answered, and a freshly initialised Postgres kept rejecting the password it had just been given, because the app was talking to a different stack's Postgres. Every stack since gets its own network and explicit hostnames like affine_db.
One later change touched this file too. My Traefik default@file middleware chain used to include an error-pages middleware, which replaced upstream 403, 404, 500 and 503 responses with a stock error page. That's friendly for visitors and terrible for debugging, because the app's real error never reaches you. A day after AFFiNE went in, every router, AFFiNE's included, was switched to the security-headers and identity-stripping middlewares only. If an app behind Traefik is giving you an error page that doesn't look like the app's own, check for that before you read the app's logs.
The first account is the admin
The header comment says it bluntly: the first account to sign up becomes the instance admin, so open the site right after the first start and register before anyone else does.
The hostname is public. Between docker compose up -d and my first visit, anyone who guessed the URL could in principle have claimed the instance. The window is small and the odds are tiny, but it's free to avoid. Either create the DNS record only after the stack is up and you've registered, or register within a minute of the first start. My notes don't record which I did, which is its own small lesson about writing things down.
What happens to registration after that, my compose file doesn't say. It sets no registration option at all, unlike AppFlowy's, where GoTrue takes a disable-signup flag. So whether strangers can still create accounts on my AFFiNE is a question for its admin panel. I haven't gone through those settings carefully, and I should, because AFFiNE's own login is the only thing in front of it.
That's deliberate, by the way. I don't put my Authelia 2FA gateway in front of the notes apps. Authelia guards the admin tools (log viewer, uptime dashboard, start page). Apps that have their own desktop or mobile clients need to reach the server directly, and a login page in the middle breaks them, the same way an SSO proxy breaks the Nextcloud mobile app. AFFiNE has a desktop app that can sign in to a self-hosted server, so it falls on the "own login" side of that line.
Local-first, which is not the same as local-only
Back to the panel. Here's what I was told, and what I've been able to confirm.
AFFiNE is a local-first app. The browser (or the desktop app) keeps a working copy of your documents, so editing is instant and keeps working when the connection drops. Changes are synced to the server in the background. "Sync storage" is how much your account holds on the server you're logged in to. When that server is your own, the number is about your own disk.
The 765 KB was the demo workspace AFFiNE creates for a new account, mostly text. The 100 GB is a default per-user quota that AFFiNE shows even on a self-hosted instance. It isn't a cloud allowance and nobody bills for it. On my box the real limit is the VPS disk, and the quota can be changed from the admin panel.
The local copy in the browser is a cache, not a second source of truth. Clearing the browser's site data wouldn't lose anything that has already synced to the server. The flip side is that the cache isn't a backup either. It only holds what that browser has opened, and it's the first thing to go when a browser profile gets reset.
That covers "where does it go". AFFiNE also runs a hosted cloud, and the same apps can be pointed at either one, so the useful habit is to check which server you're talking to. In the browser, that's the address bar: your own hostname, not AFFiNE's hosted app. In the desktop app, it's the server you signed in to. The admin panel in the menu is another tell, because it only appears on a self-hosted instance where your account is the admin. I had that menu entry, and hadn't connected it to the question.
What the domain proves, and what it doesn't
My follow-up was the one I think a lot of people starting out would ask: so if I'm on my own subdomain, I have full control and I'm self-hosted?
Mostly. The domain proves that the app and its data are served by whatever my DNS points at, not by AFFiNE's cloud. It doesn't prove anything about that machine.
Mine is a rented VPS. That's my operating system, my containers and my data, sitting on someone else's hardware. The provider can in principle read the disk, snapshot it, or lose it. That's a trade I accepted for everything on the box, and AFFiNE doesn't change it, but "self-hosted" and "physically mine" are different claims, and I'd been using them interchangeably. For notes, I'm fine with the VPS trade. For anything I'd be truly upset to see read, I'd want encryption at rest that the provider doesn't hold keys for, and that's not what this setup is.
There's also a middle layer I hadn't thought about: Cloudflare sits in front of the hostname as a proxy. It terminates the public TLS connection, which means it sees the traffic in the clear before passing it on to my server. That's the same for every app on the box, and it's a choice I made for the DDoS protection and hidden origin IP. It's still worth saying out loud in a post about "who controls my data", because the honest answer has three parties in it, not one.
And the domain doesn't give you backups. On AFFiNE's cloud, losing a disk is their problem. On my VPS, AFFiNE keeps its state in two places, the Postgres folder and the storage folder for blobs and uploads, and if the disk goes and I have no copy, the notes go with it.
To check all of this for real, rather than trusting a hostname, look at the server:
docker ps --filter name=affine --format 'table {{.Names}}\t{{.Status}}'
# affine_app, affine_db and affine_redis should be Up.
# affine_migration is absent from `docker ps` because it exited, which is correct:
docker ps -a --filter name=affine_migration --format '{{.Names}} {{.Status}}'and then at the compose file, which names exactly which folders hold the data. If those folders are on your disk and in your backup, you're self-hosted in the sense that matters. If only the first half is true, you're self-hosted in the sense that's fragile.
How it's watched
AFFiNE gets checked from two places. My NocoBase instance runs an uptime workflow across every service and recorded AFFiNE as up with a 200. Uptime Kuma has it too. My setup notes give it AFFiNE's /info endpoint as the health URL rather than the root page, with a caveat that if it ever returns 404 the root works too. Kuma listed AFFiNE as up when its stats first came through to NocoBase.
Neither check would tell me that the data is safe, only that the web server answers. A green light on an app with no backup is a very specific kind of false comfort.
Day to day
Honestly, AFFiNE has very little in it: the demo workspace and not much else, nothing I couldn't recreate. That's not a criticism of the app. It's a good editor, the whiteboard mode is something none of the other candidates have, and it works in a plain browser tab with nothing installed, which is how I use most things. It's that the bulk of what I'd have put in Notion (lists with dates, amounts and statuses, and reminders on top) went into NocoBase that same week, and long-form notes are the part of Notion I use least.
I haven't imported a Notion export into it. I haven't tried the desktop app against my server. I haven't tested real-time collaboration, because there's nobody to collaborate with. So my verdict on AFFiNE so far is about how it deploys and runs, not about living in it for months.
Maintenance, and the backup I still owe it
Updates first. The image is on :stable, which is a moving tag. My update notes put AFFiNE in the "has a database schema: pin an exact version, upgrade deliberately, back up first" category and say to take a database dump before upgrading. Renovate now watches the repo and opens a pull request per image, but it can only bump pinned tags, so for AFFiNE it does nothing until I pin. Pinning is on my list, along with the others in that category.
Now the backups, which is where this post was always going.
At the end of that exchange about the sync panel, the assistant offered to write a Postgres dump and storage backup script for AFFiNE. I didn't take it up at the time. Here's where that leaves things in mid-October 2026.
The off-site backup job I trust is the one for Nextcloud, which goes to Backblaze. A backlog item lists the data folders of the apps I set up later that week to add to that job (the push-notification server, the uptime monitor, the bookmark manager, the RSS reader and so on). Its list doesn't mention AFFiNE at all. I haven't checked the job's actual config, so I can't say for certain that affine/db and affine/storage never leave the VPS. But nothing I've written down says they do, so I'm assuming they don't.
Two things make that less bad than it sounds, and neither is a plan. There's very little in AFFiNE yet. And the browser cache holds a copy of whatever I've opened, which is not a backup but would make a disaster slightly less total.
What it needs is boring:
# Logical dump: portable, restorable into a newer Postgres, small for an app this size
docker exec affine_db pg_dump -U affine -Fc affine > /srv/backups/affine-$(date +%F).dump
# Blobs, uploads and config, straight from the bind mounts
tar -C /srv/docker/affine -czf /srv/backups/affine-files-$(date +%F).tgz storage configplus those two files in the off-site job, plus a restore test. For the test I'd bring up a copy of the stack on a different hostname with empty folders, restore into it, and open a page:
# on a scratch copy of the stack, before starting the app
docker compose up -d db
docker exec -i affine_db pg_restore -U affine -d affine --clean --if-exists < affine-YYYY-MM-DD.dump
tar -C /srv/docker/affine-restore -xzf affine-files-YYYY-MM-DD.tgz
docker compose up -dI haven't run any of those lines on the server yet. They're the shape of what's needed, not a tested procedure. My NocoBase even has a "Backup & restore tests" table with the line "An untested backup is not a backup" at the top of it, and I can't point to an AFFiNE restore test recorded there. Writing this down in public is partly a way of making myself do it.
Open items, and what I'd do differently
As of writing: pin the AFFiNE image; review registration settings in the admin panel; confirm whether the AFFiNE folders are in the off-site job and add them if not; run one restore test; try the desktop app against my server. And at some point decide between AFFiNE and AppFlowy, so one of two nearly empty Postgres instances can go.
What I'd do differently is mostly about order. I'd write the backup lines before the first docker compose up -d, not after the first panic about a quota. I'd register the admin account and only then create the DNS record. And I'd ask "where does my data live and who else can touch it" before deploying, not because a settings panel startled me into it.
The irony isn't lost on me. I moved off a cloud service partly to own my data, and the first concrete difference is that losing it is now my job.