Skip to content

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#

WhatWhereNotes
Workspaces, members, hospitals, connections, requisitions, decisions, the study list, jobs, audit trailThe platform's databaseEvery record belongs to one workspace.
Connector credentials and webhook signing secretsThe database, sealedEncrypted with a key held outside the database. See Security.
API keys and agent tokensThe database, as hashesThe values themselves are not kept.
Configuration snapshotsThe storage layerFiles. No credentials and no patient data.
ImagesThe hospital's archiveStreamed on request and not stored. See Imaging.
Full database exportsStorage the operator choosesNever 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.

ProviderWhat it isWhere the bytes areState
Convex file storageconvexManaged object storage beside the database. No set-up; the default for configuration snapshots and exports.The Convex deployment's regionAvailable
S3-compatible buckets3Any 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 createdPlanned
On-premises NAS vaultnasA 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 premisesPlanned

The kinds of file the layer holds:

KindWhatPatient data
backup.configConfiguration snapshotNo
export.auditAudit exportNo

Adding a provider

  1. Implement StorageAdapter (put, url, remove) in apps/web/convex/lib/storage.ts and add it to the adapter table.
  2. Mark the provider available in packages/core/src/storage.ts.
  3. Set the STORAGE_PROVIDER variable 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 snapshotNot in a snapshot
  • Workspace profile, modules, retention period, viewer choice
  • Hospitals
  • Connections: type, settings, capabilities, authorisation status and reference, schedule
  • Members: name, email, role
  • Protocol options and rules
  • Webhook addresses and events
  • API key names, prefixes and scopes
  • Agent names
  • Connector credentials
  • API keys, agent tokens, webhook signing secrets
  • Passwords
  • Requisitions, decisions, studies or anything else about a patient
  • The audit trail
  • A member with settings.manage can 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.

Shell, from the repository root
# 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-report

In order, the script:

  1. 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.
  2. Runs convex export into a .partial file in the target.
  3. 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.
  4. 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.
  5. Records the run on the deployment, success or failure, so the admin console shows when the last export happened and where it went.
Exit codeMeaning
0Done.
1The export failed.
2Bad arguments, or the target cannot be used.
3Another run holds the lock.
4The export is complete but could not be recorded.
  • Nothing schedules the export. scripts/README.md shows 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 scheduleAfter
Finished and cancelled jobs45 days
Webhook delivery records30 days
The log of text messages sent90 days