s365b.jobs.retention¶
Retention: remove backups older than a repository’s policy, reclaim space.
Point-in-time retention. With “keep restore points for N days”, every backup taken in the last N days can still be restored exactly. A version is removed only when no restore point in that window needs it:
it was replaced or deleted before the window started (
valid_tois before the cutoff), orit is a deletion marker older than the window (the item was deleted from Microsoft 365 more than N days ago).
So anything still in Microsoft 365 is always kept, however old, and items deleted from Microsoft 365 stay restorable for N days after deletion. Objects on hold are never touched.
After the catalog is pruned, blobs nothing refers to any more are deleted
from the repository (Repository.compact()). That step holds the
repository’s lock exclusively, so it never overlaps a backup.
Attributes¶
Classes¶
How long the app keeps its own records, and when retention runs. |
|
What a retention policy would remove now. |
Functions¶
|
A repository's retention period in days; |
|
Count what a policy of |
|
Apply a repository's retention policy and reclaim space. |
|
Delete audit log entries, alerts and run logs older than the housekeeping settings. |
Module Contents¶
- class s365b.jobs.retention.HousekeepingSettings[source]¶
Bases:
s365b.core.settings_store.SettingsGroupHow long the app keeps its own records, and when retention runs.
- Variables:
audit_log_days – Audit log entries older than this are deleted. Six years by default, a common choice for compliance programs.
alert_days – Alerts (events) older than this are deleted.
run_log_days – Job runs’ own logs older than this are deleted (the runs themselves are kept).
run_hour – Hour of the day (server time) when retention runs.
- s365b.jobs.retention.keep_days(repo: s365b.db.models.RepositoryConfig) int | None[source]¶
A repository’s retention period in days;
Nonemeans forever.
- class s365b.jobs.retention.Preview[source]¶
What a retention policy would remove now.
- Variables:
versions – Item versions removed.
items – Items removed entirely (no version left).
size – Logical size of the removed versions. Space actually freed is usually less: content shared with kept versions stays.
held_objects – Objects on hold, whose backups are kept regardless.
cutoff – Start of the kept window;
Nonefor “keep forever”.
- async s365b.jobs.retention.preview(s: sqlalchemy.ext.asyncio.AsyncSession, repository_fk: int, days: int | None, now: datetime.datetime | None = None) Preview[source]¶
Count what a policy of
dayswould remove from a repository now.- Parameters:
s – Database session.
repository_fk – Repository.
days – Retention period;
Nonefor forever.now – Current time.
- Returns:
The counts.
- s365b.jobs.retention.CATALOG_BEHIND = "No space was reclaimed: this repository holds backups this server's database does not know...[source]¶
- async s365b.jobs.retention.run_retention(services: s365b.core.services.Services, repository_fk: int, *, requested_by: str = 'scheduler') tuple[int, bool][source]¶
Apply a repository’s retention policy and reclaim space.
- Parameters:
services – Process services.
repository_fk – Repository.
requested_by – Who started it.
- Returns:
The job run ID, and whether it was skipped because a backup was writing to the repository (the caller retries later).
- async s365b.jobs.retention.purge_records(services: s365b.core.services.Services, now: datetime.datetime | None = None) dict[str, int][source]¶
Delete audit log entries, alerts and run logs older than the housekeeping settings.
- Parameters:
services – Process services.
now – Current time.
- Returns:
Rows deleted per table.