Skip to content

Backups

How a senior's memory bank is backed up and put back. The family-facing steps are on Backing up memories; this page is the format, the code, and the nightly job.

Three decisions shape it:

  • The archive is built by the client, from the ordinary list routes. The web app builds it in the browser and the nightly script in Node, both from the same shared module. The Worker has no export route, no new table, and nothing to deploy for this.
  • Restoring is a plan carried out with the ordinary write routes. A restored photo goes through POST /banks/:id/photos like a new one, so it passes the same checks (the required description, the size caps), and the server gives it a new id. Nothing is ever changed or deleted on a restore.
  • A backup is Markdown a person can read and fix. The facts the app needs sit between --- marks; the words sit under headings. Pictures and videos are beside their .md files, untouched.

The archive

tom-memories-2026-10-12.zip
├── README.md                        whose, when, counts, how to put it back
├── backup.json                      format, bank id, exportedAt, fingerprint, counts
├── photos/
│   ├── lake-george-3f9a21c7.md      the photo's words
│   └── lake-george-3f9a21c7.jpg     the photo
├── videos/
│   ├── skydive-e5f6a7b8.md
│   └── skydive-e5f6a7b8.mov
├── memory-screens/
│   ├── stories-babe-ruth.md         the family's photo and song on an app memory
│   ├── stories-babe-ruth.jpg
│   └── stories-gary.md              an app picture removed
└── quiz/
    └── which-neighborhood-q1a2b3c4.md

File names are the item's title as a slug plus the first eight characters of its id, so they are stable from one backup to the next and never collide. Memory-screen files are named by the memory's id in the app.

A photo's file:

---
type: photo
id: 3f9a21c7-…
file: lake-george-3f9a21c7.jpg
contentType: image/jpeg
sizeBytes: 123456
takenOn: 1975-07-04
location: Lake George, New York
credit: Aunt May
songTitle: Moon River
songArtist: Andy Williams
songAlbum: …
songPreviewUrl: https://audio-ssl.itunes.apple.com/…
songArtworkUrl: https://is1-ssl.mzstatic.com/…
createdAt: 2026-10-01T12:00:00.000Z
---

# Lake George

## Description

Tom and Nyna on the dock, waving.

## Memory details

- You were 25 when you got married
- The water was cold

## Song

Moon River, Andy Williams

A tags: line, when the photo has tags, holds them as typed on the web: tags: Family, Summer, Lake George.

The song… lines are the song chosen for the photo's own memory (stored on the server under bank-photo-<id>, or bank-video-<id> for a video); on restore it is put on the new id. A video's file also has width and height.

A memory-screen file carries memoryId, appPicture: removed when the app's own picture was taken off, photo and photoId when the family put a photo on it (with ## Photo title and ## Photo description in the body), and the song… lines when they chose a song. A question's file carries topic, difficulty, and set (the set's name), with ## Choices as a checklist where [x] marks the right answer, and ## Source quote.

backup.json is what the nightly job reads to tell backups apart. A file a person wrote by hand without one still restores.

Where the code is

Piece Role
packages/shared/src/bank-archive.ts The format: archiveFromContents (the API's lists to an archive), archiveEntries (to zip entries), readArchive (back from entries, tolerant), planRestore (what to add), contentItems and fingerprintText (change detection)
packages/shared/src/zip.ts Writing and reading zip files with no library; stored entries out, stored or deflated entries in
apps/web/src/backup-section.tsx The Backup section: Download (fetch, zip in the browser, save) and Restore (read, plan, carry out)
apps/api/scripts/backup-banks.ts The nightly job: sign in, fingerprint each bank, write a zip only on change, and the launchd install
apps/api/tests/bank-archive.test.ts The format, round-tripped through a real zip; hand-edited files; the plan; change detection
apps/api/tests/zip.test.ts The zip writer and reader, including a fixture made by the zip command
apps/web/tests/backup-section.test.tsx The section end to end against the stubbed API

The shared module names its imports with .ts (allowImportingTsExtensions in the shared and web tsconfigs) so Node runs the script from source, the way the account scripts already run.

The restore plan

planRestore(archive, current) compares the archive with what the bank holds now and answers steps and skips:

  • A photo or video is skipped when the bank has one with the same id, or the same title and size (its id changes when restored into a new bank). A skipped photo whose song is missing still gets its song.
  • A memory-screen photo is skipped on the same rule; a song when the same preview is already chosen; a removed app picture when already removed.
  • A question is skipped when one with the same prompt exists. A set is skipped whole when a set with the same name exists.

Steps run in order: media, memory screens, questions, sets. One failing step is reported and the rest still run.

The nightly job

pnpm backup signs in to the Worker, lists every bank the account can see, and for each one builds the archive's text, hashes it (SHA-256 of fingerprintText), and compares it with latest.json beside the last zip. Nothing changed: it logs that and moves on. Anything changed, including a word edited or an item removed: it fetches the pictures, writes a new dated zip, and says what changed (added 1 photo; changed 1 song; removed nothing). Removals count because the backup must match what the family now wants, and the older zip still holds what was removed.

Files are never overwritten. A second backup on one day gets the time appended (tom-memories-2026-10-12-153005.zip). latest.json holds the fingerprint, the date, the file name, and every item's text, which is what the next run diffs against.

Setting it up

  1. Copy backup.env.example to backup.env at the repo root (git ignores it) and fill in the email and password of a Loved One account. A superadmin's reaches every bank. The folder defaults to ~/Senior Health Backups; the example points it at the shared drive, so a copy also lives off the laptop.
  2. Try it without writing anything:
cd ~/Documents/GitHub/SilverApp && pnpm backup --dry-run
  1. Run it for real once, then schedule it:
cd ~/Documents/GitHub/SilverApp && pnpm backup
cd ~/Documents/GitHub/SilverApp && pnpm backup --schedule 03:30

--schedule writes ~/Library/LaunchAgents/com.equalentry.senior-health-backup.plist and loads it. launchd runs the job every day at that time through a login shell (so pnpm is found), and runs a missed one when the laptop next wakes. The log is ~/Library/Logs/senior-health-backup.log. pnpm backup --unschedule removes the job.

Other options: --bank <id> (repeatable) limits the run, --force writes a zip even with no change, --dir and --api override the environment. Against the local Worker: pnpm backup --api http://localhost:8787 --dir /tmp/backups with the seed's Loved One.

The password sits in plain text in backup.env on the laptop. That is the trade for a job that runs unattended; the file is ignored by git and should stay out of any shared folder.

Putting a person back after a loss

  1. Make their account and bank again if needed: pnpm add-person "<name>" --remote (Adding a tester).
  2. In the web app, choose them under Whose memories on Home, open More, then Backup, and restore their newest zip. The page warns when the zip's name differs from the person's; that is expected when the bank is new.
  3. Connect their phone with a new code. The phone fetches the restored memories when the app next opens.

Ids change on restore, which nothing outside the server depends on. App opens from before the loss stay in their Google Sheet backup (App opens).

Limits

  • The zip is built in memory, in the browser or in Node. A bank's media is at most a few hundred megabytes today (videos are capped at 80 MB each), which is fine; a bank many times that size would want a streamed writer.
  • ZIP64 is not supported: a single file or whole zip over 4 GB, or more than 65,535 files. Encrypted zips are refused.
  • A memory-screen picture keeps its title, description, Illustration label, and the app's catalog id for a copy of the app's own; a video comes back without its poster until it is opened on the web.
  • Once a senior's memories are in the bank (pnpm memories:migrate), the backup holds every memory's words (memories/) and the bank's copy of every picture the app ships. Before that, the app's own pictures and words are not in it; they live in the repository.