summaryrefslogtreecommitdiff
path: root/detonate.sh
blob: 5defdaeb885cdb544756cc952f5e33a746a9a9b9 (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
# This script finds and blows away directory landmines in a MinIO-mounted filesystem
# where files are supposed to go but directories already exist. Use with caution.

LOG="/tmp/minio_detonation.log"
ERROR_LOG="/tmp/rclonemasto-dump.log"
TARGET_BASE="/assets/minio-data/mastodon"

echo "[*] Scanning for blocking directories... 💣" | tee "$LOG"

grep 'is a directory' "$ERROR_LOG" | \
awk -F': open ' '{print $2}' | \
sed 's/: is a directory//' | \
sort -u | while read -r bad_path; do
    if [ -d "$bad_path" ]; then
        echo "[💥] Nuking: $bad_path" | tee -a "$LOG"
        rm -rf "$bad_path"
    else
        echo "[✔️] Skipped (not a dir): $bad_path" | tee -a "$LOG"
    fi
done

echo "[✅] All blocking directories removed. Re-run rclone and finish the war." | tee -a "$LOG"