# Current State Discovery Plan

**Purpose**: Gather all critical information about the existing setup to ensure successful migration and optimization

**Status**: Required before any migration attempt

## 1. INFRASTRUCTURE DISCOVERY

### Hardware & System Information
- [ ] **Server Hardware Details**
  - CPU specifications (cores, architecture, capabilities)
  - RAM capacity and configuration
  - Storage devices (SSDs, HDDs, sizes, mount points)
  - GPU hardware (NVIDIA/AMD/Intel for acceleration)
  - Network interfaces and configuration

- [ ] **Operating System Details**
  - OS version and distribution
  - Kernel version
  - Installed packages and versions
  - System services currently running
  - Firewall configuration (ufw, iptables)

### Network Configuration
- [ ] **Current Network Setup**
  - IP address ranges and subnets
  - Domain name currently in use
  - SSL certificates (Let's Encrypt, custom CA)
  - DNS configuration (local DNS, external)
  - Port mappings and exposed services
  - Reverse proxy configuration (if any)

## 2. CURRENT SERVICES INVENTORY

### Docker Services
- [ ] **Container Discovery**
  - All running containers (`docker ps -a`)
  - Docker images in use (`docker images`)
  - Docker networks (`docker network ls`)
  - Docker volumes and their contents (`docker volume ls`)
  - Docker Compose files location and content

### Service-Specific Details
- [ ] **Database Services**
  - PostgreSQL: databases, users, data size, configuration
  - Redis: configuration, data persistence, memory usage
  - InfluxDB: databases, retention policies, data size
  - Any other databases (MySQL, MongoDB, SQLite)

- [ ] **Media Services**
  - Jellyfin: media library locations, user accounts, plugins
  - Immich: photo storage paths, user accounts, configurations
  - Other media services (Plex, Emby, etc.)

- [ ] **Web Services**
  - Nextcloud: data directory, database backend, user accounts
  - Any web applications and their configurations
  - Static websites or custom applications

- [ ] **Monitoring & Management**
  - Existing monitoring (Prometheus, Grafana, etc.)
  - Log management systems
  - Backup systems currently in place
  - Management interfaces (Portainer, etc.)

## 3. DATA & STORAGE DISCOVERY

### Storage Layout
- [ ] **Current Storage Structure**
  - Mount points and filesystem types
  - Data directory locations for each service
  - Storage usage and capacity
  - Backup locations and schedules
  - RAID configuration (if any)

### Data Volumes
- [ ] **Critical Data Identification**
  - Database data directories
  - Media libraries (movies, TV shows, photos)
  - User configuration files
  - SSL certificates and keys
  - Application data and logs

## 4. SECURITY & ACCESS DISCOVERY

### Authentication
- [ ] **Current Auth Systems**
  - User accounts and authentication methods
  - LDAP/Active Directory integration
  - OAuth providers in use
  - API keys and service tokens

### Security Configuration
- [ ] **Current Security Measures**
  - Firewall rules and exceptions
  - VPN configuration (if any)
  - fail2ban or intrusion detection
  - SSL/TLS configuration
  - Password policies and storage

## 5. INTEGRATION & DEPENDENCIES

### Service Dependencies
- [ ] **Inter-service Communication**
  - Which services depend on others
  - Database connections and credentials
  - Shared storage dependencies
  - Network communication requirements

### External Integrations
- [ ] **Third-party Services**
  - Cloud storage integrations
  - Email services for notifications
  - DNS providers
  - Content delivery networks
  - Backup destinations

## 6. PERFORMANCE & USAGE PATTERNS

### Current Performance
- [ ] **Baseline Metrics**
  - CPU, memory, and disk usage patterns
  - Network bandwidth utilization
  - Service response times
  - Peak usage times and loads

### User Access Patterns
- [ ] **Usage Analysis**
  - Which services are actively used
  - User count per service
  - Access patterns (internal vs external)
  - Critical vs non-critical services

## 7. BACKUP & DISASTER RECOVERY

### Current Backup Strategy
- [ ] **Existing Backups**
  - What is currently backed up
  - Backup schedules and retention
  - Backup destinations (local, remote)
  - Recovery procedures and testing
  - RTO/RPO requirements

## 8. CONFIGURATION FILES & CUSTOMIZATIONS

### Service Configurations
- [ ] **Custom Configurations**
  - Docker Compose files
  - Application configuration files
  - Environment variables
  - Custom scripts and automation
  - Cron jobs and systemd services

---

# DISCOVERY EXECUTION PLAN

## Phase 1: Automated Discovery (1-2 hours)
**Goal**: Gather system and service information automatically

### Script 1: System Discovery
```bash
./discovery_scripts/system_info_collector.sh
```
**Collects**: Hardware, OS, network, storage information

### Script 2: Service Discovery  
```bash
./discovery_scripts/service_inventory_collector.sh
```
**Collects**: All running services, containers, configurations

### Script 3: Data Discovery
```bash
./discovery_scripts/data_layout_mapper.sh
```
**Collects**: Storage layout, data locations, usage patterns

## Phase 2: Manual Review (2-3 hours)
**Goal**: Validate automated findings and gather missing details

### Review Tasks:
1. **Validate Service Inventory**
   - Confirm all services are identified
   - Document any custom configurations
   - Identify critical vs non-critical services

2. **Security Configuration Review**
   - Document authentication methods
   - Review firewall and security settings
   - Identify certificates and keys

3. **Integration Mapping**
   - Map service dependencies
   - Document external integrations
   - Identify customizations

## Phase 3: Risk Assessment (1 hour)
**Goal**: Identify migration risks based on current state

### Risk Analysis:
1. **Data Loss Risks**
   - Identify critical data that must be preserved
   - Assess backup completeness
   - Plan data migration strategy

2. **Service Disruption Risks**
   - Identify dependencies that could cause failures
   - Plan service migration order
   - Prepare rollback strategies

3. **Configuration Risks**
   - Document configurations that must be preserved
   - Identify hard-to-migrate customizations
   - Plan configuration migration

---

# DELIVERABLES

After completing discovery, we'll have:

1. **Current State Report** - Complete inventory of existing setup
2. **Migration Gap Analysis** - What's missing from current migration plan
3. **Risk Assessment Matrix** - Specific risks and mitigation strategies
4. **Updated Migration Plan** - Revised plan based on actual current state
5. **Rollback Procedures** - Specific procedures for your environment

---

# CRITICAL QUESTIONS TO ANSWER

Before proceeding, we need answers to these key questions:

1. **What is your actual domain name?** (replaces yourdomain.com placeholders)
2. **What services are you currently running?** (to ensure none are missed)
3. **Where is your critical data stored?** (to ensure no data loss)
4. **What are your uptime requirements?** (to plan maintenance windows)
5. **Do you have a staging environment?** (to test migration safely)
6. **What's your rollback tolerance?** (how quickly can you revert if needed)

**Recommendation**: Execute the discovery plan first, then revise the migration approach based on actual current state rather than assumptions.