phase 17: restore script — per-bucket size reporting, full DB row count verification
This commit is contained in:
+18
-3
@@ -90,17 +90,32 @@ spec:
|
|||||||
|
|
||||||
for bucket in stonks-raw-market stonks-raw-news stonks-raw-filings stonks-normalized stonks-llm-prompts stonks-llm-results stonks-lakehouse stonks-audit; do
|
for bucket in stonks-raw-market stonks-raw-news stonks-raw-filings stonks-normalized stonks-llm-prompts stonks-llm-results stonks-lakehouse stonks-audit; do
|
||||||
if [ -d "\${DIR}/minio/\${bucket}" ]; then
|
if [ -d "\${DIR}/minio/\${bucket}" ]; then
|
||||||
echo " Restoring \${bucket}..."
|
BCOUNT=\$(find "\${DIR}/minio/\${bucket}/" -type f 2>/dev/null | wc -l)
|
||||||
|
BSIZE=\$(du -sh "\${DIR}/minio/\${bucket}/" 2>/dev/null | cut -f1)
|
||||||
|
echo " Restoring \${bucket}: \${BSIZE} (\${BCOUNT} files)..."
|
||||||
mc mb --ignore-existing "backup/\${bucket}" 2>/dev/null || true
|
mc mb --ignore-existing "backup/\${bucket}" 2>/dev/null || true
|
||||||
mc mirror --overwrite --quiet "\${DIR}/minio/\${bucket}/" "backup/\${bucket}" 2>/dev/null || echo " (empty or error)"
|
mc mirror --overwrite "\${DIR}/minio/\${bucket}/" "backup/\${bucket}" 2>&1 | tail -1
|
||||||
|
echo " \${bucket}: done"
|
||||||
|
else
|
||||||
|
echo " \${bucket}: not in backup, skipping"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "[3/3] Verifying..."
|
echo "[3/3] Verifying..."
|
||||||
|
echo ""
|
||||||
|
echo "=== Restore Summary ==="
|
||||||
|
echo " PostgreSQL dump: \$(du -h "\${DIR}/stonks.pgdump" | cut -f1)"
|
||||||
PGPASSWORD="\${POSTGRES_PASSWORD}" psql \
|
PGPASSWORD="\${POSTGRES_PASSWORD}" psql \
|
||||||
-h "\${POSTGRES_HOST}" -p "\${POSTGRES_PORT}" \
|
-h "\${POSTGRES_HOST}" -p "\${POSTGRES_PORT}" \
|
||||||
-U "\${POSTGRES_USER}" -d "\${POSTGRES_DB}" \
|
-U "\${POSTGRES_USER}" -d "\${POSTGRES_DB}" \
|
||||||
-c "SELECT 'companies=' || count(*) FROM companies UNION ALL SELECT 'documents=' || count(*) FROM documents UNION ALL SELECT 'intelligence=' || count(*) FROM document_intelligence;"
|
-c "SELECT 'companies' as tbl, count(*) as rows FROM companies UNION ALL SELECT 'documents', count(*) FROM documents UNION ALL SELECT 'intelligence', count(*) FROM document_intelligence UNION ALL SELECT 'impacts', count(*) FROM document_impact_records UNION ALL SELECT 'trends', count(*) FROM trend_windows UNION ALL SELECT 'recommendations', count(*) FROM recommendations ORDER BY tbl;"
|
||||||
|
echo ""
|
||||||
|
echo " MinIO restored:"
|
||||||
|
for bucket in stonks-raw-market stonks-raw-news stonks-raw-filings stonks-normalized stonks-llm-prompts stonks-llm-results stonks-lakehouse stonks-audit; do
|
||||||
|
REMOTE_COUNT=\$(mc ls --recursive "backup/\${bucket}" 2>/dev/null | wc -l)
|
||||||
|
echo " \${bucket}: \${REMOTE_COUNT} objects"
|
||||||
|
done
|
||||||
|
|
||||||
echo "=== Restore complete ==="
|
echo "=== Restore complete ==="
|
||||||
EOJOB
|
EOJOB
|
||||||
|
|||||||
Reference in New Issue
Block a user