s365b.core.engine

The backup engine: drives a module’s backup of one protected object.

It connects the three parts that do not know about each other: the module (what to read), the repository (where content goes) and the catalog (what was stored when).

Attributes

Classes

ObjectResult

Outcome of backing up one protected object.

BackupEngine

Runs module backups and records the results.

Module Contents

s365b.core.engine.MAX_PENDING = 500[source]
s365b.core.engine.EXTRAS_BATCH = 200[source]
s365b.core.engine.log[source]
class s365b.core.engine.ObjectResult[source]

Outcome of backing up one protected object.

Variables:
  • object_fk – Protected object row ID.

  • stats – What was stored.

  • checkpoints – Number of checkpoints committed.

  • error – Error message if the backup failed part-way.

  • changes – (change, version) for each item added, changed or deleted, only if the object had been backed up before.

  • track_changes – Whether changes is collected (not the object’s first backup, nor the first with a new module version).

  • extras – Extra copies added to items (see BackupModule.extra_copies()).

  • extras_missing – Current items still without an extra copy after this run (e.g. messages that cannot be restored yet).

  • extras_error – Why the last extras pass stopped, if it failed.

object_fk: int[source]
stats: s365b.core.catalog.VersionStats[source]
checkpoints: int = 0[source]
error: str | None = None[source]
changes: list[tuple[str, s365b.modules.sdk.ItemVersion]] = [][source]
track_changes: bool = False[source]
extras: int = 0[source]
extras_missing: int = 0[source]
extras_error: str | None = None[source]
class s365b.core.engine.BackupEngine(db: s365b.db.session.Database, repo: s365b.storage.repository.Repository, repository_fk: int)[source]

Runs module backups and records the results.

Parameters:
  • db – Database.

  • repo – Open repository for content.

  • repository_fk – Database ID of that repository.

db[source]
repo[source]
repository_fk[source]
async backup_object(module: s365b.modules.sdk.BackupModule, ctx: s365b.modules.sdk.ModuleContext, row: s365b.db.models.ProtectedObjectRow, *, run_fk: int | None = None, on_stats: collections.abc.Callable[[s365b.core.catalog.VersionStats], None] | None = None) → ObjectResult[source]

Back up one protected object incrementally.

Errors inside the module are caught and reported in the result; everything up to the last checkpoint stays committed, so the next run resumes from there.

Parameters:
  • module – The module that owns the object.

  • ctx – Module context for this job.

  • row – The protected object’s catalog row.

  • run_fk – Current job run, recorded on each version.

  • on_stats – Called after each commit with what that commit stored (for live progress).

Returns:

The outcome.