set -euo pipefail
cd /opt/infisical
printf '== now ==\n'; date -Is
printf '== backups dirs ==\n'
find /opt/infisical/backups -maxdepth 1 -mindepth 1 -type d -printf '%TY-%Tm-%Td %TH:%TM:%TS %p\n' 2>/dev/null | sort || true
printf '== backup contents summary ==\n'
for d in /opt/infisical/backups/infisical-backup-*; do
  [ -d "$d" ] || continue
  echo "-- $d --"
  ls -la "$d" | sed -E 's/  +/ /g' | awk '{print $6,$7,$8,$9}'
  [ -f "$d/manifest.txt" ] && { echo 'manifest:'; sed -n '1,80p' "$d/manifest.txt" | sed -E 's/(PASSWORD|SECRET|KEY|TOKEN|AUTH|ENCRYPTION).*/[REDACTED]/I'; }
  [ -f "$d/SHA256SUMS" ] && echo 'has_sha256=true'
done
printf '== restore test artefacts/logs candidates ==\n'
find /opt/infisical -maxdepth 4 \( -iname '*restore*' -o -iname '*test*' -o -iname '*log*' \) -printf '%TY-%Tm-%Td %TH:%TM:%TS %p\n' 2>/dev/null | sort | tail -80 || true
printf '== scripts mtimes ==\n'
stat -c '%y %n' /opt/infisical/bin/backup-infisical.sh /opt/infisical/bin/restore-test-infisical.sh 2>/dev/null || true
printf '== current compose/env mtimes (no content) ==\n'
stat -c '%y %n' /opt/infisical/docker-compose.prod.yml /opt/infisical/.env 2>/dev/null || true
