Initial commit: combine nas_tool, nas_webdav, sync-utils
This commit is contained in:
Executable
+115
@@ -0,0 +1,115 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check Snapshot Size
|
||||
# Determine how much space the snapshot is actually using
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== Check Snapshot Size ==="
|
||||
echo ""
|
||||
|
||||
# Current disk space
|
||||
FREE_SPACE=$(df / | tail -1 | awk '{print $4}')
|
||||
FREE_SPACE_GB=$(echo "scale=2; $FREE_SPACE / 1024 / 1024" | bc)
|
||||
USED_SPACE=$(df / | tail -1 | awk '{print $3}')
|
||||
USED_SPACE_GB=$(echo "scale=2; $USED_SPACE / 1024 / 1024" | bc)
|
||||
|
||||
echo "📊 Current Disk Status:"
|
||||
echo " Used: ${USED_SPACE_GB}GB"
|
||||
echo " Free: ${FREE_SPACE_GB}GB"
|
||||
echo ""
|
||||
|
||||
# Check if snapshot exists in APFS
|
||||
echo "🔍 Checking if snapshot exists in APFS..."
|
||||
APFS_CHECK=$(diskutil apfs listSnapshots / 2>/dev/null | grep -i "timemachine" || echo "NOT_FOUND")
|
||||
if [ "$APFS_CHECK" = "NOT_FOUND" ]; then
|
||||
echo " ❌ Snapshot NOT found in APFS"
|
||||
echo " This means it's a GHOST ENTRY - not taking any space!"
|
||||
echo ""
|
||||
echo " The snapshot entry you see is just a stale database record."
|
||||
echo " It's not actually consuming disk space."
|
||||
echo ""
|
||||
echo " ✅ Your space is already available!"
|
||||
echo " The ghost entry will clear on restart."
|
||||
else
|
||||
echo " ✅ Snapshot found in APFS"
|
||||
echo " $APFS_CHECK"
|
||||
echo ""
|
||||
echo " This snapshot IS taking up space."
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Try to get snapshot size
|
||||
SNAPSHOT=$(tmutil listlocalsnapshots / 2>/dev/null | grep -v "Snapshots for disk" | grep -v "^$" | head -1)
|
||||
if [ -n "$SNAPSHOT" ]; then
|
||||
echo "📸 Snapshot Details:"
|
||||
echo " Name: $SNAPSHOT"
|
||||
echo ""
|
||||
|
||||
echo " Attempting to calculate snapshot size..."
|
||||
SNAP_DATE=$(echo "$SNAPSHOT" | sed 's/.*\.\([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}\)\.backup/\1/')
|
||||
|
||||
# Try calculatedrift
|
||||
DRIFT_OUTPUT=$(sudo tmutil calculatedrift "$SNAPSHOT" 2>&1 || echo "ERROR")
|
||||
if echo "$DRIFT_OUTPUT" | grep -qi "size\|bytes\|GB\|MB"; then
|
||||
echo " Size information:"
|
||||
echo "$DRIFT_OUTPUT" | grep -i "size\|bytes\|GB\|MB" | head -5 | sed 's/^/ /'
|
||||
else
|
||||
echo " ⚠️ Could not calculate size (snapshot may be corrupted/stuck)"
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Container vs Volume analysis
|
||||
echo "📦 Container Analysis:"
|
||||
CONTAINER_TOTAL=$(diskutil info / | grep 'Container Total' | awk '{print $4, $5}')
|
||||
CONTAINER_FREE=$(diskutil info / | grep 'Container Free' | awk '{print $4, $5}')
|
||||
VOLUME_USED=$(diskutil info / | grep 'Volume Used Space' | awk '{print $4, $5, $6}')
|
||||
|
||||
echo " Container Total: $CONTAINER_TOTAL"
|
||||
echo " Container Free: $CONTAINER_FREE"
|
||||
echo " Volume Used: $VOLUME_USED"
|
||||
echo ""
|
||||
|
||||
# Calculate if there's unaccounted space
|
||||
CONTAINER_TOTAL_GB=$(diskutil info / | grep 'Container Total' | awk '{print $3}' | tr -d 'GB')
|
||||
CONTAINER_FREE_GB=$(diskutil info / | grep 'Container Free' | awk '{print $3}' | tr -d 'GB')
|
||||
VOLUME_USED_GB=$(diskutil info / | grep 'Volume Used Space' | awk '{print $4}' | tr -d 'GB')
|
||||
|
||||
CONTAINER_USED_GB=$(echo "$CONTAINER_TOTAL_GB - $CONTAINER_FREE_GB" | bc)
|
||||
DISCREPANCY=$(echo "$CONTAINER_USED_GB - $VOLUME_USED_GB" | bc)
|
||||
|
||||
echo " Container Used: ~${CONTAINER_USED_GB}GB"
|
||||
echo " Volume Used: ~${VOLUME_USED_GB}GB"
|
||||
if (( $(echo "$DISCREPANCY > 1" | bc -l) )); then
|
||||
echo " ⚠️ Unaccounted: ~${DISCREPANCY}GB"
|
||||
echo " This could be:"
|
||||
echo " - APFS snapshots"
|
||||
echo " - Other volumes"
|
||||
echo " - Reserved space"
|
||||
else
|
||||
echo " ✅ Space accounting looks normal"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Summary
|
||||
echo "=== Summary ==="
|
||||
echo ""
|
||||
if [ "$APFS_CHECK" = "NOT_FOUND" ]; then
|
||||
echo "✅ The snapshot is a GHOST ENTRY - it's NOT taking any space!"
|
||||
echo ""
|
||||
echo " Your disk space is already available."
|
||||
echo " The entry will clear on restart."
|
||||
echo ""
|
||||
echo " If 'System Data' is still growing when you delete files,"
|
||||
echo " it's because Time Machine is creating NEW snapshots,"
|
||||
echo " not because of this old ghost entry."
|
||||
else
|
||||
echo "⚠️ The snapshot IS in APFS and may be taking space."
|
||||
echo ""
|
||||
echo " To free the space, you need to:"
|
||||
echo " 1. Remove Time Machine destination"
|
||||
echo " 2. Restart your Mac"
|
||||
echo " 3. The snapshot should be cleared"
|
||||
fi
|
||||
echo ""
|
||||
Reference in New Issue
Block a user