Skip to content

Storage

Where notes live

Every feed is a folder in DATA_DIR (/data in the container), and every note a file in it, <id>.md or <id>.png and so on, exactly as posted, with its metadata in a small .json file next to it:

data/
├── .secret                        # signs cookies and tokens; back it up
├── homelab-7f3k2q9x4m8wz/
│   ├── .readid                    # the feed's read id; don't edit it by hand
│   ├── .feed.json                 # title, description, title image
│   ├── .password                  # only on a protected feed
│   ├── Vq3xH8mTn2KfLw0aZr9bYe.md
│   ├── .Vq3xH8mTn2KfLw0aZr9bYe.md.json
│   └── Hc4yP9sZt1NvKd6WoGx3Ab.png
└── alerts-q9x2m7hd4k1pv/

From 0.28.0 a note's id is random and carries no time. On the first start after the update, existing notes get new ids and keep their dates. Old links to single notes and to files stop working. A note's references to its own feed's files are rewritten; links from one feed into another feed's notes are not. If the main key is in a key service and it is down while this migration is still pending, notefeed does not start.

You can read, grep, copy or delete the files directly; a file you put in a feed's folder is a note too. notefeed writes as the owner of the data folder, so create it yourself (mkdir data); PUID and PGID choose another owner. Symlinks and anything that isn't a feed folder are ignored. If you copy a feed's folder to make another feed, remove .readid from the copy: two feeds can't share a read link.

A picture is stored as the server processed it: at most 2560 px, without EXIF data such as GPS position (see Pictures). Pictures stored by an older notefeed keep the metadata they were posted with; on the file system, exiftool -all= <file> removes it from one.

Keeping notes in git

Since the notes are your files, data can be a git repository. Keep .secret, .readid and .password out of a public one: with the secret anyone can compute older feeds' read links, .readid is a feed's read link, .password its password hash.

Databases

With NOTEFEED_STORAGE notefeed keeps everything in a database instead: sqlite (one file) or postgres (a server, which several notefeed containers can share). The API, the read links and the web UI are the same.

fs (default) sqlite postgres
Where folders in DATA_DIR one file, NOTEFEED_DATABASE_URL (default DATA_DIR/notefeed.db) a PostgreSQL server, NOTEFEED_DATABASE_URL
NOTEFEED_SECRET optional required required
Containers one one several, with the same secret
Back up with copy the folder sqlite3 notefeed.db ".backup out.db" pg_dump

The tables are created, and updated on upgrade, when notefeed starts. With a database there is no hand-editing of files, and moving an existing data folder into a database is not built in: a new instance on a database starts empty.

PostgreSQL

services:
  notefeed:
    image: ghcr.io/notefeed/notefeed:latest
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      NOTEFEED_STORAGE: postgres
      NOTEFEED_DATABASE_URL: postgres://notefeed:${POSTGRES_PASSWORD}@db:5432/notefeed
      NOTEFEED_SECRET: ${NOTEFEED_SECRET}      # openssl rand -hex 32
    depends_on:
      db:
        condition: service_healthy

  db:
    image: postgres:17-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: notefeed
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: notefeed
    volumes:
      - notefeed-db:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U notefeed"]
      interval: 5s
      retries: 10

volumes:
  notefeed-db:

Put POSTGRES_PASSWORD and NOTEFEED_SECRET in a .env file next to it, then docker compose up -d. A password with @ or / in the URL must be percent-encoded. Back up with docker compose exec db pg_dump -U notefeed notefeed > notefeed.sql, and keep the secret with it.

Image bytes outside the database

With a database backend, NOTEFEED_IMAGES says where the bytes of image notes go; everything else stays in the database, and images are still served by notefeed under the read link.

Where each part of a note ends up, by the two settings; readers always go through notefeed:

flowchart LR
  reader[Reader] --> nf[notefeed]
  nf -->|"NOTEFEED_STORAGE=fs"| dir["DATA_DIR: a folder per feed, a file per note"]
  nf -->|"sqlite or postgres"| db[(Database: feeds, notes, metadata)]
  db -->|"NOTEFEED_IMAGES=db"| rows[Image bytes in the note's row]
  db -->|"=fs"| folder["NOTEFEED_IMAGES_DIR"]
  db -->|"=s3"| bucket[(S3 bucket)]
NOTEFEED_IMAGES Where the bytes are Use it when
db (default) in the note's row the instance is small; one thing to back up
fs one file per image in NOTEFEED_IMAGES_DIR one container with many images
s3 one object per image in a bucket several containers, which must all reach every image

An S3-compatible object store

Any store that speaks S3 works, hosted (Hetzner, Scaleway, Cloudflare R2, AWS) or your own (MinIO, Garage). Create a private bucket and a key that may read, write and delete in it; objects are named by a random key, so the bucket shows neither feed names nor note ids.

# .env
NOTEFEED_STORAGE=postgres
NOTEFEED_IMAGES=s3
NOTEFEED_S3_ENDPOINT=https://s3.example.com
NOTEFEED_S3_BUCKET=notefeed-images
NOTEFEED_S3_REGION=us-east-1
NOTEFEED_S3_ACCESS_KEY=<access key>
NOTEFEED_S3_SECRET_KEY=<secret key>

If the store is unreachable, pictures fail and text notes keep working. Going from db to fs or s3 works at any time: old images stay where they are and are still served. Going between fs and s3 strands the old images until they are moved.

Encryption at rest

With NOTEFEED_ENCRYPTION_KEY set, or the main key in a key service, notefeed encrypts what it stores before it reaches the database or the image store, so a copy of either, a dump or a snapshot of the disk can't be read without the key. Each feed has its own data key: its notes, images, metadata, settings and feed password are encrypted with it (AES-256-GCM). The data keys are stored next to their feeds, encrypted with the main key, which is never stored. Feed names and read ids are stored only as fingerprints, so the database doesn't hand anyone a way into a feed. The database's own housekeeping stays readable: ids, sizes and times.

How the keys wrap each other, from the key you keep down to what is stored; nothing below the main key is readable without it:

flowchart TB
  main["Main key: NOTEFEED_ENCRYPTION_KEY or OpenBao, never stored"] -->|wraps| dk["A data key per feed, stored with the feed"]
  main -->|wraps| fk["The fingerprint key, stored in the database"]
  dk -->|"encrypts (AES-256-GCM)"| notes[Notes, metadata, settings, feed password]
  dk -->|encrypts| imgs[Image bytes, in the database or the image store]
  fk -->|"turns feed names and read ids into"| fp[Fingerprints]

It needs a database backend; on the file system backend notefeed refuses to start with a key. While notefeed runs, it holds the key, so encryption at rest doesn't protect against someone on the running server.

openssl rand -hex 32   # the main key

Keep the key safe and apart from the backups. Without it nothing can be read back, by anyone. notefeed refuses to start on an encrypted database without the key, or with another key.

A note that can't be decrypted

A note whose stored copy doesn't decrypt (damaged, or changed behind notefeed's back) never breaks its feed. The feed's page, the read-only view, the API and MCP list it in its place as a damaged note ("unreadable": true in the API), RSS leaves it out, and reading it alone answers 500 with the code unreadable. It can still be deleted. Each such read is an error line in the log naming the note's id, and counts in notefeed_notes_unreadable_total when metrics are on.

Turning it on for existing data

Set the key and restart. At start, notefeed gives every feed its data key and stores names and read ids as fingerprints. With several containers, stop them all and start them all with the key: one still running without it would write plain rows next to the encrypted ones, and the next start refuses such a database. Notes stored before stay readable, and are encrypted with POST /api/operator/reseal, a batch at a time, while notefeed serves:

curl -X POST -H "Authorization: Bearer $NOTEFEED_OPERATOR_TOKEN" -H "Content-Type: application/json" \
  -d '{"limit": 500}' https://notes.example.com/api/operator/reseal

It answers resealed, skipped (notes that changed meanwhile, or whose image is missing), failed, left and a next cursor to send as "after" until it is null. A call without a body takes the defaults. Notes that were skipped or failed stay plain; run it again from the start (without "after") until a run reseals nothing and nothing is left. It is safe to stop at any point: an image's encrypted copy is written first and the plain one removed last.

Changing the main key

Put the new key in NOTEFEED_ENCRYPTION_KEY, the old one in NOTEFEED_ENCRYPTION_OLD_KEYS, and restart. At start, notefeed wraps every data key again under the new key; no note or image is touched, so this takes seconds however much is stored. Then remove the old key. With several containers, restart them all together: one still on the old key can't open what the others re-wrapped.

The main key in OpenBao

With NOTEFEED_KMS=openbao the main key stays in OpenBao's Transit engine and never reaches notefeed: notefeed asks OpenBao to wrap and unwrap the data keys, with an AppRole that can be revoked, and OpenBao's audit log shows every unwrap. notefeed keeps no data key past the request that needed it, so every request that opens a feed is one entry there. It replaces NOTEFEED_ENCRYPTION_KEY; the two are refused together. The settings are in Configuration.

In OpenBao, make a derived Transit key (derived, so each data key is bound to its feed) and an AppRole whose policy allows exactly this:

bao secrets enable transit
bao write -f transit/keys/notefeed derived=true
bao auth enable approle
bao policy write notefeed - <<'POLICY'
path "transit/encrypt/notefeed" { capabilities = ["update"] }
path "transit/decrypt/notefeed" { capabilities = ["update"] }
path "transit/rewrap/notefeed"  { capabilities = ["update"] }
path "transit/keys/notefeed"    { capabilities = ["read"] }
POLICY
bao write auth/approle/role/notefeed token_policies=notefeed token_ttl=1h token_max_ttl=24h \
  secret_id_bound_cidrs=10.0.0.0/24 token_bound_cidrs=10.0.0.0/24   # notefeed's private network
bao read -field=role_id auth/approle/role/notefeed/role-id            # NOTEFEED_OPENBAO_ROLE_ID
bao write -f -field=secret_id auth/approle/role/notefeed/secret-id    # NOTEFEED_OPENBAO_SECRET_ID

notefeed logs in at start and renews its token itself. To change the secret id, make a new one, restart notefeed with it, and destroy the old one (bao write auth/approle/role/notefeed/secret-id-accessor/destroy secret_id_accessor=…).

While OpenBao doesn't answer, notefeed shows a maintenance page and the API answers 503 with the code unavailable and Retry-After. Every feed is affected, since no data key is kept. /health reports "keys": "unavailable". notefeed starts even then, and serves again as soon as OpenBao answers, without a restart.

Moving from a local key: set NOTEFEED_KMS=openbao and its settings, move the key from NOTEFEED_ENCRYPTION_KEY to NOTEFEED_ENCRYPTION_OLD_KEYS, and restart. At start, notefeed wraps every data key again under OpenBao, as for a changed main key. Then remove the old key: from then on a copy of the server holds no key at all.

Rotating the key gives it a new version. Older versions still unwrap until you retire them, and retiring one makes everything only it wrapped unreadable, for good. In this order:

  1. bao write -f transit/keys/notefeed/rotate.
  2. Restart every notefeed container. At start each database is wrapped again under the new version, and the log says so (re-wrapped the keys under the current main key, with the key id openbao:notefeed:v<n>). A database that opened has nothing left on an older version.
  3. Only then retire the old versions: bao write transit/keys/notefeed/config min_decryption_version=<n>. Backups made before step 2 need the old versions too: retiring them makes those backups unreadable, which is the point after a leak and a loss otherwise. If a database still holds keys of a retired version, notefeed refuses to start and names the version; lowering min_decryption_version again restores it, as long as the version was not trimmed.

Cleaning up the image store

An image is written before its note and deleted after it, so a stop in between leaves a file or object no note refers to. With NOTEFEED_OPERATOR_TOKEN set, the operator's endpoint finds and removes them:

# Report only
curl -H "Authorization: Bearer $NOTEFEED_OPERATOR_TOKEN" https://notes.example.com/api/operator/images/unreferenced
# Report and remove
curl -X DELETE -H "Authorization: Bearer $NOTEFEED_OPERATOR_TOKEN" https://notes.example.com/api/operator/images/unreferenced

The answer counts what is unreferenced (older than an hour), deleted, failed, too_recent and missing (notes whose bytes are gone; they show as broken images). It reads the whole listing, so run it occasionally, as a daily cron. Only names that look like notefeed's image keys are touched; one bucket per instance, or two instances delete each other's images. With metrics on, each run updates the notefeed_images_* gauges.

Moving images between stores

POST /api/operator/images/move moves image bytes into the store NOTEFEED_IMAGES names now, from wherever they are. Set the new store, restart, then:

curl -X POST -H "Authorization: Bearer $NOTEFEED_OPERATOR_TOKEN" -H "Content-Type: application/json" \
  -d '{"from": "db"}' https://notes.example.com/api/operator/images/move
# from a folder: {"from": "fs", "dir": "/data/images"}
# from a bucket: {"from": "s3", "endpoint": "…", "bucket": "…", "access_key": "…", "secret_key": "…"}

One call moves limit notes (100 by default) and answers moved, skipped, missing, failed, left and a next cursor to send as "after" until it is null. It is safe to stop at any point: each image is copied first and the old bytes removed last. Posting goes on meanwhile.