# Server Migration & Cleanup Tools

This directory contains all the tools and documentation needed for migrating applications from the old server to a new clean server.

## Files in this Directory

### Documentation
- **OFFLINE_MIGRATION_GUIDE.md** - ⭐ **START HERE** - Complete step-by-step guide for offline migration
- **SERVER_MIGRATION_PLAN.md** - Complete migration strategy and overview
- **NEW_SERVER_PREPARATION.md** - Detailed guide for preparing the new server
- **PREPARATION_CHECKLIST.md** - Quick checklist for server preparation
- **QUICK_REFERENCE.md** - Cheat sheet with essential commands
- **MIGRATION_CHECKLIST_TEMPLATE.md** - Template checklist for tracking each application migration
- **README.md** - This file

### Preparation Scripts
- **prepare-new-server.sh** - Automated script to prepare new server with all required software

### Analysis Scripts
- **inventory-applications.sh** - Lists all applications, Apache configs, databases, and disk usage
- **analyze-databases.sh** - Analyzes all databases, identifies unused tables and databases
- **find-unused-files.sh** - Finds old files, backups, logs, and unused directories

## 🚀 Quick Start (Offline-Friendly)

**If you're working offline, start with:**
1. Read **OFFLINE_MIGRATION_GUIDE.md** - Complete step-by-step instructions
2. Run **quick-start.sh** - Interactive helper script
3. Use **QUICK_REFERENCE.md** - Cheat sheet for commands

## Quick Start

### Step 0: Prepare New Server (FIRST!)
1. **SSH to new server**: `ssh root@vps2.scala4.com`
2. **Copy preparation script** from old server:
   ```bash
   scp /var/www/html/wordpress6/wordpress/EP/migration/prepare-new-server.sh root@vps2.scala4.com:/root/
   ```
3. **Run preparation script** on new server:
   ```bash
   chmod +x /root/prepare-new-server.sh
   /root/prepare-new-server.sh
   ```
4. **See NEW_SERVER_PREPARATION.md** for detailed instructions

### Step 1: Inventory on Old Server
1. **Run on old server first** to get inventory:
   ```bash
   cd /var/www/html/wordpress6/wordpress/EP/migration
   ./inventory-applications.sh > ../inventory-report.txt
   ./analyze-databases.sh > ../database-analysis.txt
   ./find-unused-files.sh > ../unused-files-report.txt
   ```

### Step 2: Copy Migration Tools to New Server
2. **Copy this entire migration directory** to the new server:
   ```bash
   rsync -avz /var/www/html/wordpress6/wordpress/EP/migration/ root@vps2.scala4.com:/root/migration/
   ```

### Step 3: Start Migration
3. **Follow the migration plan** in SERVER_MIGRATION_PLAN.md
4. **Use the checklist template** for each application migration

## Usage

All scripts are executable. Run them with:
```bash
./script-name.sh
```

## Important Notes

- Always backup before making changes
- Test on new server before DNS cutover
- Keep old server running for 48-72 hours after migration
- Review all analysis reports carefully before deleting anything




