golem-flask-backend / emergency_cleanup.sh
mememechez's picture
Deploy final cleaned source code
ca28016
#!/bin/bash
echo "🚨 EMERGENCY CLEANUP SCRIPT FOR QWEN2GOLEM"
echo "=========================================="
echo ""
echo "⚠️ WARNING: This will delete backup files to free disk space"
echo " Press Ctrl+C to cancel, or wait 5 seconds to continue..."
sleep 5
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR/aether_mods_and_mems"
# Step 1: Remove old backup files (keeping only the latest)
echo ""
echo "πŸ“¦ Step 1: Removing old backup files..."
echo "----------------------------------------"
# List backups by size
echo "Current backup files:"
ls -lh *.backup_* 2>/dev/null | head -10
# Keep only the newest backup, remove others
if ls *.backup_* 1> /dev/null 2>&1; then
# Get the newest backup file
NEWEST_BACKUP=$(ls -t *.backup_* 2>/dev/null | head -1)
echo "Keeping newest backup: $NEWEST_BACKUP"
# Remove all other backups
for file in *.backup_*; do
if [ "$file" != "$NEWEST_BACKUP" ]; then
echo " Removing: $file ($(du -h "$file" | cut -f1))"
rm -f "$file"
fi
done
else
echo "No backup files found"
fi
# Step 2: Remove duplicate pattern files
echo ""
echo "πŸ“¦ Step 2: Removing duplicate pattern files..."
echo "----------------------------------------------"
# Remove checkpoint files older than 7 days
find . -name "*checkpoint*.json" -mtime +7 -exec rm -v {} \;
# Remove old conversation files
find . -name "gemini_golem_conversation_*.json" -mtime +7 -exec rm -v {} \;
find . -name "consciousness_discourse_*.json" -mtime +7 -exec rm -v {} \;
# Step 3: Compress large JSON files
echo ""
echo "πŸ“¦ Step 3: Compressing large JSON files..."
echo "------------------------------------------"
for file in *.json; do
if [ -f "$file" ]; then
SIZE=$(du -m "$file" | cut -f1)
if [ "$SIZE" -gt 100 ]; then
echo " Compressing $file (${SIZE}MB)..."
gzip "$file"
fi
fi
done
# Step 4: Clean temporary files
echo ""
echo "πŸ—‘οΈ Step 4: Cleaning temporary files..."
echo "---------------------------------------"
# Remove log files older than 3 days
find "$SCRIPT_DIR" -name "*.log" -mtime +3 -exec rm -v {} \;
# Remove Python cache
find "$SCRIPT_DIR" -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null
# Remove .tmp files
find "$SCRIPT_DIR" -name "*.tmp" -exec rm -v {} \;
# Step 5: Show results
echo ""
echo "πŸ“Š CLEANUP RESULTS"
echo "=================="
# Show disk usage after cleanup
echo "Disk usage after cleanup:"
df -h /
# Show aether directory size
echo ""
echo "Aether directory size:"
du -sh "$SCRIPT_DIR/aether_mods_and_mems"
# Show memory status
echo ""
echo "Memory status:"
free -h
echo ""
echo "βœ… Cleanup complete!"
echo ""
echo "πŸ’‘ Additional recommendations:"
echo " 1. Consider moving old aether files to external storage"
echo " 2. Set up automatic cleanup to run weekly"
echo " 3. Limit pattern generation to prevent future buildup"