Instance backup with restore by CLI (#109) #122
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MassiveDynamic/kataba!122
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/109-instance-backup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #109.
GET /admin/backup, admins only, 404 otherwise). It streams the whole instance as a ZIP, one file at a time, as the download proceeds:backup.jsonwith users, settings, categories with their images, guides (working copy, all versions, deleted ones), pages with their images and the menu, plus every original, variant and attachment under its storage key.PACKAGE_FORMAT_VERSION, with one sharedreadFormatVersion. Backups from a newer kataba are refused.npm run restore -- <backup.zip>in the container, and only into an empty instance (no users, settings, categories, guides, pages or menu items). Files are written first, then all data in one transaction; on failure the files are removed and the database stays empty. Guides, categories, pages, steps, images and menu items keep their ids, so links and QR labels keep working. Annotations get new ids, and search texts are rebuilt.dist/restore.mjs. Everything is bundled except Prisma, which comes from the standalone server'snode_modules. The Dockerfile builds and copies it, and the Lingui macro plugin is now shared with vitest (linguiMacroPlugin.mjs).yazl3.3.1 andyauzl3.4.0, because fflate writes no ZIP64 and multi-GB backups need it; dev dependencyrolldown1.2.16.ImageStoragegainedsize.Tests: backup description and format version, which files a backup contains, writing a backup ZIP and reading it back, storage
size, and e2e for the admin download and the 404 for others. Typecheck, lint, all 552 unit tests and all 69 e2e tests pass.Manual round trip: I backed up the dev database, restored it into an emptied scratch database, and backed it up again.
backup.jsonis identical apart from its timestamp, all files match byte for byte, and the search texts match. A restore into a database that already had data was refused without writing any files.Not verified: the restore inside a built image, because the image does not build on
developmenteither (#121).🤖 Generated with Claude Code