From 85e0ef75809945ee1593d8e412e7bee1c24d0445 Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Sun, 12 Apr 2026 14:46:47 -0700 Subject: [PATCH] phase 17: backup script now reports per-bucket sizes and file counts --- scripts/backup.sh | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/scripts/backup.sh b/scripts/backup.sh index f5f92b7..245959a 100755 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -79,13 +79,35 @@ 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 mc ls "backup/\${bucket}" >/dev/null 2>&1; then - echo " Mirroring \${bucket}..." - mc mirror --quiet "backup/\${bucket}" "\${DIR}/minio/\${bucket}/" 2>/dev/null || echo " (empty or error)" + COUNT=\$(mc ls --recursive "backup/\${bucket}" 2>/dev/null | wc -l) + if [ "\${COUNT}" -gt 0 ]; then + echo " \${bucket}: \${COUNT} objects, mirroring..." + mc mirror "backup/\${bucket}" "\${DIR}/minio/\${bucket}/" 2>&1 | tail -1 + SIZE=\$(du -sh "\${DIR}/minio/\${bucket}/" 2>/dev/null | cut -f1) + echo " \${bucket}: done (\${SIZE})" + else + echo " \${bucket}: empty, skipping" + fi else - echo " Bucket \${bucket} not found, skipping" + echo " \${bucket}: not found, skipping" fi done + echo "" + echo "=== Backup Summary ===" + echo " PostgreSQL: \$(du -h "\${DIR}/stonks.pgdump" | cut -f1)" + MINIO_TOTAL=\$(du -sh "\${DIR}/minio/" 2>/dev/null | cut -f1) + echo " MinIO total: \${MINIO_TOTAL}" + 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 + BSIZE=\$(du -sh "\${DIR}/minio/\${bucket}/" 2>/dev/null | cut -f1) + BCOUNT=\$(find "\${DIR}/minio/\${bucket}/" -type f 2>/dev/null | wc -l) + echo " \${bucket}: \${BSIZE} (\${BCOUNT} files)" + fi + done + TOTAL=\$(du -sh "\${DIR}/" 2>/dev/null | cut -f1) + echo " Total backup size: \${TOTAL}" + echo "[3/3] Writing manifest..." cat > "\${DIR}/manifest.json" <