stouputils.backup.retrieve module#
- get_backup_sort_key(filename: str) str[source]#
Returns a sortable key for backup filenames.
- Parameters:
filename – Backup filename or path
- Returns:
Filename normalized for chronological sorting
- get_all_previous_backups(
- backup_folder: str,
- all_before: str | None = None,
Retrieves all previous backups in a folder and maps each backup to a dictionary of file paths and their hashes.
- Parameters:
backup_folder – The folder containing previous backup zip files
all_before – Path to the latest backup ZIP file (If endswith “/latest.zip” or “/”, the latest backup will be used)
- Returns:
file_hash}, ordered from newest to oldest
- Return type:
Dictionary mapping backup file paths to dictionaries of {file_path
- is_file_in_any_previous_backup(
- file_path: str,
- file_hash: str,
- previous_backups: dict[str, dict[str, str]],
Checks if a file with the same hash exists in any previous backup.
- Parameters:
file_path – The relative path of the file
file_hash – The SHA-256 hash of the file
previous_backups – Dictionary mapping backup zip paths to their stored file hashes
- Returns:
True if the file exists unchanged in any previous backup, False otherwise