Sitemap
Norman Sutorius

Norman Sutorius

Passionate Software Developer & Cloud Foundry Contributor ⚙️

Part 2: One File. One Database. No Drama.

3 min readJan 2, 2026

--

Press enter or click to view image in full size

At some point, every developer gets tired.

Tired of, database clusters, replicas, failover diagrams & “managed” services that mostly manage your anxiety.

I didn’t want to run a database platform.
I just wanted to run an app.

And that’s when the obvious question appeared:

What if a single file is enough?

Spoiler! It is.

SQLite Is Not a Compromise. It’s a Decision.

SQLite still has a reputation problem.

People treat it like decaf coffee, acceptable, but not serious. That’s nonsense. SQLite is fast, stable, battle-tested, local & boring (in the best possible way) Most importantly, SQLite is honest.

No hidden network hops, No magic, No background complexity quietly waiting to fail.

Just, a file on a very fast disk.

On a Mac mini, that’s not a limitation. That’s the sweet spot.

The Storage Location: Boring on Purpose

My production database lives here:

/Users/apprunner/storage/local_s3/cupcounter/production.sqlite3

No mystery.
No container voodoo.
No “where are my data actually stored?”

If I want to see my data, I know exactly where to look. That matters more than people admit.

Deployments Should Not Own Backups

Important clarification, Backups do NOT run as part of the deployment.

During a deploy, Kamal does exactly what it should do:

  • build the image
  • run migrations
  • restart containers

That’s it.

Backups are a different concern. Coupling backups to deployments is how people lose data while feeling safe. Deployments should be fast. Backups should be boring. Those responsibilities don’t belong together.

Backups as a Kamal Accessory

Instead of hooking backups into deploys, I run them as a long-running Kamal accessory.

Get Norman Sutorius’s stories in your inbox

Join Medium for free to get updates from this writer.

That means:

  • backups are time-based, not event-based
  • deploys stay predictable
  • no “deploy failed because backup failed” nonsense

Here’s the full setup:

accessories:
backup:
image: normansutorius/cupcounter
host: homeserver.local
directories:
- "/Users/apprunner/storage/local_s3/cupcounter:/rails/storage"
env:
clear:
DB_PATH: /rails/storage/production.sqlite3
BACKUP_DIR: /rails/storage/backups
BACKUP_KEEP: 5
cmd: "bash -lc 'while true; do /rails/bin/backup_sqlite; sleep 86400; done'"

What this does:

  • runs continuously
  • creates one backup per day
  • keeps only the last N backups
  • runs independently of deploys

No cron, No scheduler, No external service. Just a loop and sleep.

Boring. Reliable. Correct.

The Backup Script (Simple, Explicit, Safe)

This is the full backup_sqlite script:

#!/usr/bin/env bash
set -euo pipefail
# Configuration via ENV with defaults
DB_PATH="${DB_PATH:-/rails/storage/production.sqlite3}"
BACKUP_DIR="${BACKUP_DIR:-/rails/storage/backups}"
KEEP="${BACKUP_KEEP:-5}"
mkdir -p "$BACKUP_DIR"
TIMESTAMP="$(date +"%Y-%m-%d_%H-%M-%S")"
TEMP_FILE="${BACKUP_DIR}/temp_${TIMESTAMP}.sqlite3"
BACKUP_FILE="${BACKUP_DIR}/production_${TIMESTAMP}.sqlite3"
echo "[backup] Vacuum from ${DB_PATH} -> ${BACKUP_FILE}"
# Create a consistent backup using VACUUM INTO
sqlite3 "$DB_PATH" "VACUUM INTO '${TEMP_FILE}';"
mv "${TEMP_FILE}" "${BACKUP_FILE}"
echo "[backup] Created ${BACKUP_FILE}"
# Rotation: keep only the newest KEEP files
cd "${BACKUP_DIR}"
ls -1t production_*.sqlite3 | sed -e "1,${KEEP}d" | xargs -r rm --
echo "[backup] Rotation done (keep=${KEEP})."

Why this matters:

  • VACUUM INTO guarantees a consistent snapshot
  • the database stays online
  • no file corruption
  • rotation is explicit and predictable
  • failure is loud (set -euo pipefail)

This is exactly how SQLite wants to be backed up.

Volumes: Persistence Without Theater

The database lives outside the container and is mounted as a volume:

volumes:
- "/Users/apprunner/storage/local_s3/cupcounter:/rails/storage"

Containers are disposable, images are replaceable & the file stays.

That’s the contract.

Simplicity vs. Database Theater

Here’s the uncomfortable truth. Most database setups exist not because they’re needed,but because they’re possible. Complexity often feels like progress. It isn’t.

Real progress is, fewer moving parts, fewer failure modes & less cognitive load. SQLite on a Mac mini delivers exactly that.

What This Setup Gives You

  • a production Rails app
  • a persistent database
  • continuous, reliable backups
  • clear ownership of your data
  • zero deploy/backup coupling
  • no ops burnout

All built on one file

Final Thought

I thought I needed a “real” database. I got a file instead.

It turns out, that was the more professional choice.

--

--

Norman Sutorius
Norman Sutorius