From 527be42f82f5742a957dfcf5bf1f666f327bedc4 Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Sun, 12 Apr 2026 14:53:19 -0700 Subject: [PATCH] =?UTF-8?q?phase=2017:=20restore=20script=20=E2=80=94=20pe?= =?UTF-8?q?r-bucket=20size=20reporting,=20full=20DB=20row=20count=20verifi?= =?UTF-8?q?cation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/restore.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index f07fd3d..00ec90c 100755 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -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 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 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 done + echo "" echo "[3/3] Verifying..." + echo "" + echo "=== Restore Summary ===" + echo " PostgreSQL dump: \$(du -h "\${DIR}/stonks.pgdump" | cut -f1)" PGPASSWORD="\${POSTGRES_PASSWORD}" psql \ -h "\${POSTGRES_HOST}" -p "\${POSTGRES_PORT}" \ -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 ===" EOJOB