e1b057f494
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
22 lines
699 B
Python
22 lines
699 B
Python
"""Restore from the most recent 'pre_migration'-tagged backup."""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from . import backup as backup_mod
|
|
|
|
|
|
class NoBackupFoundError(Exception):
|
|
"""Raised when rollback() is called with no pre_migration backup on disk."""
|
|
|
|
|
|
def rollback_to_pre_migration(*, db_url: str, images_root: Path) -> dict:
|
|
manifest = backup_mod.find_latest_backup(images_root, tag="pre_migration")
|
|
if manifest is None:
|
|
raise NoBackupFoundError(
|
|
"no pre_migration-tagged backup found under <images_root>/_backups/"
|
|
)
|
|
return backup_mod.restore_backup(
|
|
manifest=manifest, db_url=db_url, images_root=images_root,
|
|
)
|