#!/bin/bash # # Database Cleanup Utility # # Removes invalid/old data from the local database # # Usage: # ./scripts/cleanup-database.sh [--dry-run] # # Options: # --dry-run Show what would be deleted without actually deleting # set -e # Configuration LOCAL_DB_PATH="${1:-c:/mnt/okcomputer/cache.db}" DRY_RUN=false # Colors GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' BLUE='\033[0;34m' NC='\033[0m' # Parse arguments if [ "$1" = "--dry-run" ] || [ "$2" = "--dry-run" ]; then DRY_RUN=true fi if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then grep '^#' "$0" | sed 's/^# \?//' exit 0 fi echo -e "${BLUE}╔════════════════════════════════════════════════════════╗${NC}" echo -e "${BLUE}║ Database Cleanup - Auctiora Monitor ║${NC}" echo -e "${BLUE}╚════════════════════════════════════════════════════════╝${NC}" echo "" if [ ! -f "${LOCAL_DB_PATH}" ]; then echo -e "${RED}Error: Database not found at ${LOCAL_DB_PATH}${NC}" exit 1 fi # Backup database before cleanup if [ "$DRY_RUN" = false ]; then BACKUP_PATH="${LOCAL_DB_PATH}.backup-before-cleanup-$(date +%Y%m%d-%H%M%S)" echo -e "${YELLOW}Creating backup: ${BACKUP_PATH}${NC}" cp "${LOCAL_DB_PATH}" "${BACKUP_PATH}" echo "" fi # Show current state echo -e "${BLUE}Current database state:${NC}" sqlite3 "${LOCAL_DB_PATH}" <