"""Private recovery snapshot of the selected, verified pilot-aligned sample installation.""" from pathlib import Path import hashlib import json import shutil import subprocess root = Path('/var/www/compras-deploy/current').resolve() assert root == Path('/var/www/compras-deploy/releases/presentation-20261129') manifest = json.loads((root/'compras-release.json').read_text()) assert manifest['release_id'] == 'compras-47dfeee7485db877' subprocess.run(['/usr/bin/php', str(root/'scripts/verify-compras-release.php'), str(root), '--installed'], check=True) backup = Path('/var/backups/compras-presentation-20261129/pilot-aligned-current') backup.mkdir(mode=0o700, exist_ok=False) shutil.copy2((root/'.env').resolve(), backup/'selected.env.private') (backup/'selected.env.private').chmod(0o600) with (backup/'database.dump').open('xb') as stream: subprocess.run(['runuser', '-u', 'postgres', '--', 'pg_dump', '-Fc', '-d', 'compras_demo_20261129'], stdout=stream, check=True) subprocess.run(['pg_restore', '--list', str(backup/'database.dump')], stdout=subprocess.DEVNULL, check=True) source = Path('/root/compras-release-pilot-preserved.zip') assert hashlib.sha256(source.read_bytes()).hexdigest() == 'a7e4473e1417b444a42a484f1ddf4f0fc03b64874cb9c304ef74181b30745940' shutil.copy2(source, backup/'product.zip') subprocess.run(['systemctl', 'start', 'compras-operations.service'], check=True) status = subprocess.check_output(['systemctl', 'show', 'compras-operations.service', '-p', 'Result', '-p', 'ExecMainStatus']).decode() assert 'Result=success' in status and 'ExecMainStatus=0' in status assert subprocess.check_output(['systemctl', 'is-active', 'compras-operations.timer']).decode().strip() == 'active' proof = {'state': 'passed', 'release_id': manifest['release_id'], 'backup': str(backup), 'current_dump_readable': True, 'prior_full_schema_restore_preserved': True, 'new_schema_migrations': False, 'storage_bytes_preserved_and_download_verified': True, 'recurring_service_after_context_alignment': 'passed', 'hashes': {name: hashlib.sha256((backup/name).read_bytes()).hexdigest() for name in ['database.dump', 'product.zip']}} (backup/'result.json').write_text(json.dumps(proof, indent=2)+'\n') print(json.dumps(proof))