{
  "topic": "data",
  "section": {
    "n": 3,
    "name": "Deploy"
  },
  "title": "Saving data",
  "covers": "Where to keep data so it survives a redeploy: DATA_DIR and SQLite",
  "summary": "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.",
  "available": true,
  "who": {
    "connector": null,
    "api": null,
    "dashboard": null,
    "needs_human": null
  },
  "steps": {
    "any": [
      "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\").",
      "For a database use SQLite with its file under DATA_DIR (including the -wal and -shm files).",
      "Leave Embarko's two bookkeeping tables, _litestream_seq and _litestream_lock, alone. Every SQLite file under DATA_DIR has them.",
      "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.",
      "The quickstart tar command leaves out *.db files. To ship a seed database, give it another name (seed.sqlite) or drop that exclude.",
      "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."
  ],
  "prerequisites": {
    "read_first": "https://embarko.ai/docs/prerequisites",
    "user": "The person is usually not a developer. They want to know if the app is live, not how.",
    "talk": "Reply in 1-3 short plain sentences: what happened, and what the person needs to do only if something is needed. Do not show commands, API names, tokens, headers or logs, or describe the steps you took, unless the person asks for technical details. If the person is clearly a developer (uses technical terms, asks what you ran), talk to them that way for the rest of the conversation. Never show a token. Never invent a link, name or code: use only what Embarko's replies, this guide or the person give you.",
    "route": "Connector first if it is in your tools, then the HTTP API, then the upload page as a last resort.",
    "domains": "ship.embarko.ai (API), embarko.ai (website), {app-name}.embarko.app (apps): all Embarko.",
    "requires": []
  },
  "next": "Point the app's storage at DATA_DIR before deploying.",
  "related": [
    {
      "topic": "deploy",
      "why": "The deploy call",
      "url": "https://embarko.ai/docs/deploy"
    },
    {
      "topic": "files",
      "why": "Uploaded files and public links",
      "url": "https://embarko.ai/docs/files"
    }
  ],
  "links": {},
  "url": "https://embarko.ai/docs/data",
  "contents": "https://embarko.ai/docs",
  "version": "2026-11-24"
}