Skip to main content

scalio-backup

Encrypted export and import of a whole Scalio app instance, shared by the Scalio apps (Nexus first, then Citadel, Foundry, Rosetta, Beacon and Pulse, ADR 0069 wartung/W5). Used for backup/restore and for moving an instance between self-hosted and SaaS. Concept and decisions E1-E12: https://claude.ai/artifact/Ej8DFrgi4hcFDQ69dvKWZ7

Nothing in this package is secret. The password is the customer's; without it nobody (Scalio included) can open a bundle.

Bundle format (.scaliobak)

  • Outside: standard age v1 with a passphrase (scrypt, work factor 2^18), ChaCha20-Poly1305 in 64 KiB chunks. age -d backup.scaliobak > backup.tar opens it without Scalio.
  • Inside: a tar stream. manifest.json first (format scalio-backup/1, product, app and schema version, source, options, SHA-256 per part), then collections/<name>.jsonl (MongoDB Extended JSON, canonical, so dates, Int64 and ObjectIds stay exact), meta.jsonl, and for file folders files/<dir>.index.jsonl plus the files. The import checks every hash; a changed or incomplete bundle is refused before anything is written.

Classes

Every collection (and every document of a mixed meta collection) has one class: config (always exported), data (exported unless "configuration only"), cache, ephemeral, instance (never exported). Each app keeps its classes in its own backup_spec.py and a test that fails on an unclassified collection.

Use in an app

from scalio_backup import AppSpec, Preserve, apply_import, export_instance, open_bundle, recover, rollback, purge

SPEC = AppSpec(product="scalio-nexus", app_version=VERSION, collections=..., meta_ids=...,
               secret_fields={"settings": ("entra.clientSecret", ...)}, file_dirs={"hr": HR_UPLOAD_DIR},
               schema_version=current_schema, export_hook=decrypt_instance_secrets, import_hook=encrypt_again)

# export (background job): writes the encrypted bundle to a file object
manifest = await export_instance(db, SPEC, out, password, include_data=True, include_secrets=True,
                                 created_by=user_email, source={"mode": "selfhosted", "host": host, "tenant": tid})

# import, step 1: decrypt and verify into a work folder, nothing changes yet (WrongPassword, BundleError,
# IncompatibleBundle when the product differs or the bundle is newer than this instance)
bundle = open_bundle(upload, password, SPEC, target_schema=await current_schema(db))
show(bundle.preview())          # source, counts, warnings; the app adds its own (other tenant, license limits)

# import, step 2: inside the app's maintenance window (no writes, background jobs paused)
await apply_import(db, SPEC, bundle, preserve=(Preserve("app_users", {"email": me}),), imported_by=me)
bundle.cleanup()
# then: migrations, end all sessions, re-sync caches, show the checklist

await rollback(db, SPEC)        # back to the state before the import (until purge)
await recover(db, SPEC)         # on startup: cleans up an import that stopped half way
await purge(db, SPEC)           # daily: drops the rollback copy after 7 days

How the swap works: documents go into _import_<name>, then each collection is renamed to _preimport_<name> and the staging copy into its place. A journal (_backup_journal) records each step, so an interrupted import is rolled back on the next start. File folders keep their old content in .preimport/.

Routes and the classification test (0.2.0)

scalio_backup.web.backup_router(...) (extra web, FastAPI) gives every app the page Einstellungen -> Sicherung with the same paths as Nexus (/backup/status, /backup/export…, /backup/import/…): the export job in its own thread, the chunked upload (2 GB), the preview with warnings (another tenant needs a confirmation), the import under the maintenance lock (pass scalio-platform maintenance as lock: the API answers 423, no job starts, the import waits for running jobs) and the rollback for 7 days. Confirmation like «Zurücksetzen»: the password when the account has one, and always the second factor. The app gives its pieces as hooks (source_info, preserve, after_import, migrate, preview_extra, audit); call router.backup.startup() once when the API starts and purge_rollback(db, spec, lock) from the worker.

scalio_backup.scan.scan(backend_dir) finds the collections and meta ids in the app's source, check(spec, found) lists what has no class or is stale; each app runs it as a test.

Since 0.2.0 the import keeps the indexes of the collections it replaces (before, they were gone until the app created them again).

Development

pip install -e ".[dev]", then pytest -q and ruff check .. Engine tests use mongomock; with MONGO_URL set they run against a real MongoDB (CI does both). tests/vector.scaliobak is the shared test bundle (tests/make_vector.py); the age layer is checked against rage (pyrage) in both directions.

Metadata

Release files for scalio-backup 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scalio-backup 0.2.0
File Size Uploaded Provenance Actions
scalio_backup-0.2.0.tar.gz 39.3 kB With provenance Details for scalio_backup-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scalio-backup 0.2.0
File Interpreter ABI Platform Actions
scalio_backup-0.2.0-py3-none-any.whl Python 3 none any Details for scalio_backup-0.2.0-py3-none-any.whl

Total release size: 69.8 kB

Release files / scalio_backup-0.2.0.tar.gz

Download URL scalio_backup-0.2.0.tar.gz
Size 39.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3becff357ab41934835a982b8aeb9fee41f57c522bc9983778cd448eb5448e6e
BLAKE2b-256 checksum
How to use checksums
ce8f4a3268c0683da055911e3507136daead6a485740040cb7d34d8356a678be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / scalio_backup-0.2.0-py3-none-any.whl

Download URL scalio_backup-0.2.0-py3-none-any.whl
Size 30.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7634cbd73cbcefc4169eeb7776b8b09d1471df51969b568d0ec2187ca0b880a
BLAKE2b-256 checksum
How to use checksums
16fafc1bddcadcec1087122ad8f32d1b3fdd9f4971795146561dcb0e2b8be164
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for scalio-backup 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for scalio_backup-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page