stouputils.backup.consolidate module#

consolidate_backups(
zip_path: str,
destination_zip: str,
) → None[source]#

Consolidates the files from the given backup and all previous ones into a new ZIP file, ensuring that the most recent version of each file is kept and deleted files are not restored.

Parameters:
  • zip_path – Path to the latest backup ZIP file (If endswith “/latest.zip” or “/”, the latest backup will be used)

  • destination_zip – Path to the destination ZIP file where the consolidated backup will be saved

> consolidate_backups("/path/to/backups/latest.zip", "/path/to/consolidated.zip")
[INFO HH:MM:SS] Consolidating backups
[INFO HH:MM:SS] Consolidated backup created: '/path/to/consolidated.zip'
build_file_registry(
backup_paths: list[str],
) → tuple[dict[str, tuple[str, ZipInfo]], set[str]][source]#

The newest stored version of every file across backups, and the files some backup marked as deleted.

A file a backup deletes is no longer taken from older backups, while one stored in that same backup still counts.

Parameters:

backup_paths – Backup ZIP files, newest first.

Returns:

Each file name mapped to the backup holding it and its entry there, in the order the backups store them.