From 360b6bdd6975a7a4fc5c03409eb6ca80d0192c8c Mon Sep 17 00:00:00 2001 From: tegwick Date: Sat, 31 Oct 2026 01:03:11 +0100 Subject: [PATCH] Allow isolated restores under protected recovery storage Assistant: codex Assistant-Model: gpt-6.1-sol Assistant-Session: 01a18e2d-f513-7742-b8e7-12af0b744ff3 --- scripts/restore-paired-snapshot.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/restore-paired-snapshot.py b/scripts/restore-paired-snapshot.py index 28ead89..699aedb 100644 --- a/scripts/restore-paired-snapshot.py +++ b/scripts/restore-paired-snapshot.py @@ -85,7 +85,11 @@ def main() -> int: help='Local PostgreSQL image/digest; use the retained kit image ID offline') parser.add_argument('--keep-instance', action='store_true', help='Keep the isolated internal network/database for a content rehearsal') + parser.add_argument('--work-root', type=Path, default=Path('/tmp'), + help='Existing absolute parent for the private restored content directory') args = parser.parse_args() + if not args.work_root.is_absolute() or not args.work_root.is_dir(): + raise Refused('absolute_existing_work_root_required') source = args.snapshot.resolve() receipt = json.loads((source / 'receipt.json').read_text()) if receipt.get('status') != 'captured' or not receipt.get('writers_quiesced'): @@ -96,7 +100,7 @@ def main() -> int: started = time.monotonic() name = 'csoc-recovery-' + time.strftime('%Y%m%d%H%M%S', time.gmtime()) network = name + '-net' - work = Path(tempfile.mkdtemp(prefix=name + '-', dir='/tmp')) + work = Path(tempfile.mkdtemp(prefix=name + '-', dir=args.work_root)) image = run(['docker', 'image', 'inspect', args.postgres_image, '--format', '{{.Id}}']).decode().strip() if not re.fullmatch(r'sha256:[a-f0-9]{64}', image):