summaryrefslogtreecommitdiff
path: root/tothebank.sh
blob: 9522f6f2561917798913fcf0ea3811559d554163 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# Mastodon Media Audit: Find orphaned .part.* dirs & estimate space wasted
# For mounted MinIO (e.g., /assets/minio-data/mastodon)

TARGET="/assets/minio-data/mastodon/"
LOG="/tmp/mastodon_zombie_audit.log"
REPORT="/tmp/mastodon_zombie_report.txt"

echo "[*] Auditing .part.* zombie files under: $TARGET" | tee "$LOG"

# Find all part.1 or similar that are actually directories
find "$TARGET" -type d -name "part.*" > "$REPORT"

TOTAL=$(cat "$REPORT" | wc -l)
SIZE=$(du -shc $(cat "$REPORT" 2>/dev/null) 2>/dev/null | tail -1 | awk '{print $1}')

echo "[✔️] Found $TOTAL suspicious .part.* directories" | tee -a "$LOG"
echo "[📦] Estimated wasted space: $SIZE" | tee -a "$LOG"

echo "Top offenders:" | tee -a "$LOG"
du -sh $(cat "$REPORT" | head -n 20) 2>/dev/null | sort -hr | tee -a "$LOG"

echo -e "\n🚨 To delete these, run:\n  sudo xargs rm -rf < $REPORT" | tee -a "$LOG"