---
topic: data
---

[← Guide home](https://embarko.ai/docs)

# Saving data

**On this page:** Steps, Limits

> Plain words unless the person is a developer. Never invent a link, name or code. [Rules](https://embarko.ai/docs/prerequisites)

Each server app gets a folder at the DATA_DIR environment variable. It survives redeploys and restarts. Everything else on disk is wiped on every redeploy.

**Done when:** Something you saved is still there after a redeploy.

**Steps**

1. Write anything that must last under DATA_DIR, creating folders on startup. Node: path.join(process.env.DATA_DIR, "app.db"). Python: os.path.join(os.environ["DATA_DIR"], "app.db").
2. For a database use SQLite with its file under DATA_DIR (including the -wal and -shm files).
3. Leave Embarko's two bookkeeping tables, _litestream_seq and _litestream_lock, alone. Every SQLite file under DATA_DIR has them.
4. Data the app already has (a JSON file, a .db): DATA_DIR starts empty. Ship the file with the code as a seed, and on startup copy it into DATA_DIR only if it is not there yet. Then read and write only the DATA_DIR copy.
5. The quickstart tar command leaves out *.db files. To ship a seed database, give it another name (seed.sqlite) or drop that exclude.
6. Files people upload or the app generates (images, PDFs, exports) do not belong under DATA_DIR: put them in the app's file storage, which gives each one a public link and counts against a quota (see files).

**Limits**

- Data is not backed up. Tell the person.
- A startup step that diffs the live database against the app's schema and changes it to match (any ORM or migration tool can do this) will refuse to start or try to drop those two tables. Apply committed migration files instead, or declare the two tables in the schema. Never force past it.
- No managed database. window.storage (Claude Artifacts) is rejected at deploy time: use SQLite.
- Static sites have no DATA_DIR. PORT, APP_NAME, APP_VERSION, DATA_DIR and STORAGE_URL are set by Embarko and cannot be overridden, and so are CRON_SECRET for an app with schedules and STORAGE_TOKEN for file storage.

**Next:** Point the app's storage at DATA_DIR before deploying.

**Related:** [deploy](https://embarko.ai/docs/deploy) · [files](https://embarko.ai/docs/files)

---

[Guide home](https://embarko.ai/docs) · JSON: add .json