Storage and backups
The platform keeps records in its database and a small number of files in a storage layer that can be pointed at different providers. Backups come in two kinds: a configuration snapshot the platform takes itself, and a full database export the operator writes to storage they control.
What is stored where#
| What | Where | Notes |
|---|---|---|
| Workspaces, members, hospitals, connections, requisitions, decisions, the study list, jobs, audit trail | The platform's database | Every record belongs to one workspace. |
| Connector credentials and webhook signing secrets | The database, sealed | Encrypted with a key held outside the database. See Security. |
| API keys and agent tokens | The database, as hashes | The values themselves are not kept. |
| Configuration snapshots | The storage layer | Files. No credentials and no patient data. |
| Images | The hospital's archive | Streamed on request and not stored. See Imaging. |
| Full database exports | Storage the operator chooses | Never held by the platform. |
Storage providers#
Features call the storage layer and never a provider directly. Each stored file records which provider holds it, so new files can go to a new provider while older ones are still read from where they are.
| Provider | What it is | Where the bytes are | State |
|---|---|---|---|
Convex file storageconvex | Managed object storage beside the database. No set-up; the default for configuration snapshots and exports. | The Convex deployment's region | Available |
S3-compatible buckets3 | Any bucket that speaks the S3 API — AWS, Cloudflare R2, Backblaze, or MinIO in front of your own disks. For large objects and a chosen region. | Wherever the bucket is created | Planned |
On-premises NAS vaultnas | A network storage appliance you own, reached by an Epic.direct Agent on the same network. For backups that must stay on your own hardware. | Your own premises | Planned |
The kinds of file the layer holds:
| Kind | What | Patient data |
|---|---|---|
backup.config | Configuration snapshot | No |
export.audit | Audit export | No |
Adding a provider
- Implement
StorageAdapter(put,url,remove) inapps/web/convex/lib/storage.tsand add it to the adapter table. - Mark the provider available in
packages/core/src/storage.ts. - Set the
STORAGE_PROVIDERvariable on the deployment. New files then go to it; existing files stay readable from the provider recorded on each.
Configuration snapshots#
Every night at 07:15 UTC the platform writes one snapshot per workspace: a JSON file describing how the workspace is set up. The last 30 are kept for each workspace; older ones are removed along with their files.
| In a snapshot | Not in a snapshot |
|---|---|
|
|
- A member with
settings.managecan take a snapshot on demand and download any of the last 30, under Settings, Backups. - Taking a snapshot and downloading one are both written to the audit trail.
- A snapshot is a record of configuration to rebuild from by hand. There is no one-step restore from it.
Full database export#
A snapshot cannot restore a deployment. That takes a full export, which is not automatic: the operator runs scripts/backup.sh against storage they control, such as a share on their own network storage.
# Production, to a mounted share, keeping 30 days of exports
scripts/backup.sh /Volumes/vault/epicdirect
# Keep 90 days, and record a label instead of the file's path
scripts/backup.sh /Volumes/vault/epicdirect --keep-days 90 --label "NAS vault"
# Try it against the development deployment without recording the run
scripts/backup.sh ~/Backups/epicdirect-dev --dev --no-reportIn order, the script:
- Refuses to start if the target is missing, is not a directory, is not writable, or is inside the repository. A share that is not mounted therefore stops the run instead of filling a local disk.
- Runs
convex exportinto a.partialfile in the target. - Checks the file exists, is not empty and is a readable archive, then names it
epicdirect-prod-<UTC time>.zip, readable by its owner only. - Only after a good export, removes its own older exports from that directory. Sub-directories and other files are never touched, and a failed run removes nothing.
- Records the run on the deployment, success or failure, so the admin console shows when the last export happened and where it went.
| Exit code | Meaning |
|---|---|
| 0 | Done. |
| 1 | The export failed. |
| 2 | Bad arguments, or the target cannot be used. |
| 3 | Another run holds the lock. |
| 4 | The export is complete but could not be recorded. |
- Nothing schedules the export.
scripts/README.mdshows how an operator can schedule it, and how to test a restore by importing an export into a development deployment. - The script prints file names and sizes only. It authenticates with whatever the Convex command line already has and never echoes a key.
Retention#
Each workspace sets how long identified records are kept, from 30 to 3,650 days. A daily job removes finished requisitions (submitted, rejected or closed) that have not changed for longer than that, together with their suggestions. The decision record is kept in de-identified form: which protocol was chosen for which kind of study, without the patient.
The same job removes a study from the reading worklist once it was marked read longer ago than the retention period. Only the worklist’s copy goes: the archive keeps the images and its own record. A marker holding the connection and the study identifier, and no patient detail, stops the next synchronisation listing the study as new. Removing a connection deletes the studies it brought in.
| Also removed on a fixed schedule | After |
|---|---|
| Finished and cancelled jobs | 45 days |
| Webhook delivery records | 30 days |
| The log of text messages sent | 90 days |