s365b.core.engine ================= .. py:module:: s365b.core.engine .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: s365b.core.engine.MAX_PENDING s365b.core.engine.EXTRAS_BATCH s365b.core.engine.log Classes ------- .. autoapisummary:: s365b.core.engine.ObjectResult s365b.core.engine.BackupEngine Module Contents --------------- .. py:data:: MAX_PENDING :value: 500 .. py:data:: EXTRAS_BATCH :value: 200 .. py:data:: log .. py:class:: ObjectResult Outcome of backing up one protected object. :ivar object_fk: Protected object row ID. :ivar stats: What was stored. :ivar checkpoints: Number of checkpoints committed. :ivar error: Error message if the backup failed part-way. :ivar changes: ``(change, version)`` for each item added, changed or deleted, only if the object had been backed up before. :ivar track_changes: Whether ``changes`` is collected (not the object's first backup, nor the first with a new module version). :ivar extras: Extra copies added to items (see :meth:`BackupModule.extra_copies`). :ivar extras_missing: Current items still without an extra copy after this run (e.g. messages that cannot be restored yet). :ivar extras_error: Why the last extras pass stopped, if it failed. .. py:attribute:: object_fk :type: int .. py:attribute:: stats :type: s365b.core.catalog.VersionStats .. py:attribute:: checkpoints :type: int :value: 0 .. py:attribute:: error :type: str | None :value: None .. py:attribute:: changes :type: list[tuple[str, s365b.modules.sdk.ItemVersion]] :value: [] .. py:attribute:: track_changes :type: bool :value: False .. py:attribute:: extras :type: int :value: 0 .. py:attribute:: extras_missing :type: int :value: 0 .. py:attribute:: extras_error :type: str | None :value: None .. py:class:: BackupEngine(db: s365b.db.session.Database, repo: s365b.storage.repository.Repository, repository_fk: int) Runs module backups and records the results. :param db: Database. :param repo: Open repository for content. :param repository_fk: Database ID of that repository. .. py:attribute:: db .. py:attribute:: repo .. py:attribute:: repository_fk .. py:method:: 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 :async: 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. :param module: The module that owns the object. :param ctx: Module context for this job. :param row: The protected object's catalog row. :param run_fk: Current job run, recorded on each version. :param on_stats: Called after each commit with what that commit stored (for live progress). :returns: The outcome.