feat(backups): restore a whole snapshot (app + tablet) #57

Merged
jfro merged 6 commits from feat/28-snapshot-restore into main 2026-10-27 03:03:29 +00:00
Owner

Closes #28

Restore a whole backup snapshot at once, into the app or to the tablet. Only what's gone from the library comes back, always as new copies; nothing that's still there (unchanged, changed or in the trash) is touched.

Restore… on a snapshot's page → pick where → preview (how many come back, how many are left and why) → confirm. It runs in RestoreSnapshotWorker on the :backups queue, one run per user at a time, recorded in backup_restore_runs; the page shows the latest run's progress.

  • Into this app: copies in Only here, named with their folders ("Work / Plans (backup Oct 16)").
  • To your reMarkable: a copy goes back in its folder if that's still there ("Plans (backup Oct 16)"). If the folder's gone too, it's made again once ("Work (backup Oct 16)", a :folder restore) and its items go in it under their own names. A folder that's in the trash now isn't made again: its items go to the nearest live folder, else My files. Gone items always get new ids (Jeremy's call).
  • The job settles each row's new id, parent and name and fetches its files into the blob store up front, so RestoreWriter never reads the backup. The writer goes in batches (restore_batch, default 50), one commit + sync per batch, folders first, at most 20 batches per sync, and reads each snapshot's manifest once per batch.
  • Skipped: what's still in the library, what was already restored from this snapshot to the same place, what was in the trash at backup time, and (for the tablet) Only here.
  • Logger: queued, started (with counts), each item written or failed, and the run's end with its duration.

Docs: docs/backups.md ("Restoring a whole snapshot").

Tests: test/rm_analyzer/backups/restore_snapshot_test.exs (standing, preview, app run, folder made again, live folder, batches of 1 → 3 commits, folder trashed now) and the snapshot LiveView. mix precommit: 919 pass.

Not covered by the fake cloud: a real tablet. Worth one try on the tablet before shipping: delete a small folder, restore the snapshot to the reMarkable, and check the "(backup …)" folder shows up with its notebooks inside.

Closes #28 Restore a whole backup snapshot at once, into the app or to the tablet. Only what's gone from the library comes back, always as new copies; nothing that's still there (unchanged, changed or in the trash) is touched. **Restore…** on a snapshot's page → pick where → preview (how many come back, how many are left and why) → confirm. It runs in `RestoreSnapshotWorker` on the `:backups` queue, one run per user at a time, recorded in `backup_restore_runs`; the page shows the latest run's progress. - **Into this app**: copies in Only here, named with their folders ("Work / Plans (backup Oct 16)"). - **To your reMarkable**: a copy goes back in its folder if that's still there ("Plans (backup Oct 16)"). If the folder's gone too, it's made again once ("Work (backup Oct 16)", a `:folder` restore) and its items go in it under their own names. A folder that's in the trash now isn't made again: its items go to the nearest live folder, else My files. Gone items always get new ids (Jeremy's call). - The job settles each row's new id, parent and name and fetches its files into the blob store up front, so `RestoreWriter` never reads the backup. The writer goes in batches (`restore_batch`, default 50), one commit + sync per batch, folders first, at most 20 batches per sync, and reads each snapshot's manifest once per batch. - Skipped: what's still in the library, what was already restored from this snapshot to the same place, what was in the trash at backup time, and (for the tablet) Only here. - Logger: queued, started (with counts), each item written or failed, and the run's end with its duration. Docs: `docs/backups.md` ("Restoring a whole snapshot"). Tests: `test/rm_analyzer/backups/restore_snapshot_test.exs` (standing, preview, app run, folder made again, live folder, batches of 1 → 3 commits, folder trashed now) and the snapshot LiveView. `mix precommit`: 919 pass. Not covered by the fake cloud: a real tablet. Worth one try on the tablet before shipping: delete a small folder, restore the snapshot to the reMarkable, and check the "(backup …)" folder shows up with its notebooks inside.
jfro added this to the v1.6.0 milestone 2026-10-27 01:46:57 +00:00
Restore… on a snapshot previews what's gone from the library (standing/2,
restore_preview/3) and restores it in RestoreSnapshotWorker as copies in
Only here, named with their folders. Nothing still in the library is
touched; a second run skips what the first restored. Runs are recorded in
backup_restore_runs; the manifest and destination are read once per run.

Refs #28
feat(backups): restore a whole snapshot to the tablet
All checks were successful
CI / test (pull_request) Successful in 1m25s
dbffad2323
"To your reMarkable" on a snapshot's Restore… panel brings back what's
gone as new copies: in their folder if it's still there, else in the
folder made again (as a :folder restore, named "Work (backup Oct 16)",
its items keeping their names), skipping folders that are in the trash
now. The job settles each row's new id, parent and name and fetches the
files up front; RestoreWriter writes them in batches (restore_batch,
default 50) of one commit each, folders first, reading each manifest
once a batch, and keeps the run's counts until it's done.

Closes #28
fix(backups): fail a snapshot restore whose job died, so the next one can start
All checks were successful
CI / test (pull_request) Successful in 1m25s
1e977e0300
fix(backups): finish tablet restores after unpairing, and never into an unmade folder
All checks were successful
CI / test (pull_request) Successful in 1m26s
7c4315dcde
- A run :writing to the tablet whose account is gone has its unwritten
  restores failed ("your reMarkable was unpaired…"), so it finishes and
  later restores aren't refused (F2, Nye's probe).
- RestoreWriter puts an item in a folder made in the same batch only if
  that folder built; else it goes to My files, named for the backup (F3).
- The run and its Oban job go in one transaction, and a partial unique
  index lets a user have only one pending/running/writing run, so two tabs
  can't both start one.
- The job catches exits as well as raises, so either fails the run.
- Tests: manifest read once (app, and job + writer batch for the tablet),
  412 mid-write retried once, exit fails the run, the index, plus Nye's
  probes and Armstrong's folder test.
feat(backups): say when a tablet restore couldn't make folders again
All checks were successful
CI / test (pull_request) Successful in 1m26s
c3af0b3e36
Counts folders that failed apart from items (counts["folders_failed"]) and
shows it in the run's summary. Adds Armstrong's nested failed-folder test.
fix(backups): a failed restore's summary also says when folders couldn't be made
All checks were successful
CI / test (pull_request) Successful in 1m25s
352e1417e7
jfro merged commit b70b6c2772 into main 2026-10-27 03:03:29 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/rm-analyzer!57
No description provided.