Repair production backup recovery selection
This commit is contained in:
@@ -4,10 +4,15 @@ set -eu
|
||||
backup_root="${ASSISTANT_BACKUP_DIR:-/home/m/assistant-backups/postgres}"
|
||||
verify_script="${ASSISTANT_RESTORE_VERIFY_SCRIPT:-/home/m/assistant-ops/verify-postgres-restore.sh}"
|
||||
|
||||
latest="$(find "$backup_root" -mindepth 1 -maxdepth 1 -type d ! -name '.*' -printf '%f\n' | sort | tail -n 1)"
|
||||
latest="$(find "$backup_root" -mindepth 1 -maxdepth 1 -type d -regextype posix-extended -regex '.*/[0-9]{8}T[0-9]{6}Z$' -printf '%f\n' | sort | tail -n 1)"
|
||||
if [ -z "$latest" ]; then
|
||||
echo "No completed PostgreSQL backup found in $backup_root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$latest" in
|
||||
[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-9][0-9][0-9][0-9][0-9][0-9]Z) ;;
|
||||
*) echo "Selected backup directory has invalid timestamp: $latest" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
exec "$verify_script" "$backup_root/$latest"
|
||||
|
||||
@@ -45,7 +45,7 @@ $cipherPartial = $null
|
||||
$manifestPartial = $null
|
||||
|
||||
try {
|
||||
$latest = ((& ssh.exe $SshHost "find '$RemoteBackupRoot' -mindepth 1 -maxdepth 1 -type d ! -name '.*' -printf '%f\n' | sort | tail -n1") -join '').Trim()
|
||||
$latest = ((& ssh.exe $SshHost "find '$RemoteBackupRoot' -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | grep -E '^[0-9]{8}T[0-9]{6}Z$' | sort | tail -n1") -join '').Trim()
|
||||
if ($LASTEXITCODE -ne 0 -or $latest -notmatch '^\d{8}T\d{6}Z$') { throw 'No valid completed production backup found' }
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $NasBackupRoot | Out-Null
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"task_file": "dev/tasks/DEV-000099-governance-consolidation.json",
|
||||
"task_id": "DEV-000099",
|
||||
"task_file": "dev/tasks/DEV-000100-production-recovery-repair.json",
|
||||
"task_id": "DEV-000100",
|
||||
"task_revision": 1
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"task_id": "DEV-000100",
|
||||
"task_revision": 1,
|
||||
"architecture_revision": "ADR-0018",
|
||||
"base_repo_revision": "8687c9b",
|
||||
"risk_tier": "E",
|
||||
"intent": "Repair production backup and restore selection so only complete timestamped backups are eligible, and make provenance drift degrade readiness.",
|
||||
"requirement_ids": ["WP-002", "INV-CONT-001", "Production recovery must be reversible"],
|
||||
"allowed_change_scope": {"modules": [], "paths": ["deploy/verify-latest-postgres-backup.sh", "deploy/windows/Sync-PostgresBackupToNas.ps1", "deploy/windows/Test-DomovoyProductionHealth.ps1", "tests/production_recovery/**", "docs/DEPLOYMENT.md", "dev/ACTIVE_TASK.json", "dev/tasks/DEV-000100-production-recovery-repair.json"]},
|
||||
"forbidden_change_scope": {"paths": ["architecture/**", "security/**", "database/**", "contracts/**", "modules/**", "cmd/**", "adapters/**", "platform/**", ".gitea/**"]},
|
||||
"allowed_architecture_delta": {"new_cross_module_dependencies": 0, "new_canonical_owners": 0, "new_privileges": 1, "new_third_party_dependencies": 0, "new_database_owner_roles": 0},
|
||||
"contracts": {"consume": ["Production backup directory contract", "Deployment manifest evidence", "Production health projection"], "may_change": []},
|
||||
"semantic_owner": "none-operational-recovery", "canonical_state": [],
|
||||
"state_transitions": ["ineligible backup -> ignored", "verified backup -> restore candidate", "provenance/backup drift -> degraded health"],
|
||||
"side_effects_and_privileges": ["Local script changes are read-only until explicit production verification; no secret bytes are logged"],
|
||||
"persistence_and_migrations": ["No database schema or migration changes"],
|
||||
"failure_retry_restart": ["Partial/temp/pre-* directories remain untouched and are ignored; restore checks use isolated temporary PostgreSQL only"],
|
||||
"assumptions": ["Production host is docker.cin.su via docker-prod/docker SSH configuration", "docker-test remains prohibited"],
|
||||
"acceptance_scenarios": ["pre-*, partial and temp directories are ignored", "latest timestamp directory is selected deterministically", "missing/hash-invalid backup is rejected", "production health is degraded on backup or deployment provenance drift", "restore verification remains isolated and cleanup-safe"],
|
||||
"required_tests": ["shell fixture tests", "PowerShell parser", "go run ./cmd/devctl/independent", "go run ./cmd/devctl preflight -active dev/ACTIVE_TASK.json", "go run ./cmd/devctl check-diff -active dev/ACTIVE_TASK.json", "go test ./...", "go vet ./...", "git diff --check", "production read-only health evidence"],
|
||||
"terminal_gap_states": ["BLOCKED_BY_ARCHITECTURE_GAP", "BLOCKED_BY_SPEC_GAP", "BLOCKED_BY_MISSING_CAPABILITY", "BLOCKED_BY_CONFLICT"]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
$script = Get-Content -LiteralPath (Join-Path $PSScriptRoot '../../deploy/verify-latest-postgres-backup.sh') -Raw
|
||||
if ($script -notmatch "-regex '\.\*/\[0-9\]\{8\}T\[0-9\]\{6\}Z\$'") {
|
||||
throw 'restore selector does not restrict candidates to timestamp directories'
|
||||
}
|
||||
if ($script -notmatch 'invalid timestamp') { throw 'restore selector lacks timestamp fail-closed guard' }
|
||||
if ($script -match "! -name '\.\*'") { throw 'restore selector still accepts arbitrary non-hidden directories' }
|
||||
Write-Output 'verify-latest backup selector tests: PASS'
|
||||
Reference in New Issue
Block a user