# ML110 Sync Guide

**Target**: ml110 (192.168.11.10)  
**Purpose**: Clean and sync verified working files to ml110

## Overview

This guide explains how to clean the old files on ml110 and sync only verified working files from the updated project.

## Current State on ML110

**Location**: `/opt/`

```
/opt/
├── smom-dbis-138/              # Source project (config and keys)
│   ├── config/                 # Configuration files
│   ├── keys/                   # Validator and oracle keys
│   └── logs/                   # Deployment logs
└── smom-dbis-138-proxmox/      # Proxmox deployment project
    ├── config/                 # Proxmox configuration
    ├── scripts/                 # Deployment scripts
    ├── install/                # Installation scripts
    └── docs/                   # Documentation
```

## What Will Be Synced

### smom-dbis-138-proxmox (Complete Sync)
- ✅ All updated configuration files
- ✅ All verified scripts
- ✅ All install scripts
- ✅ All library files
- ✅ Updated documentation
- ❌ Excludes: logs, .git, node_modules

### smom-dbis-138 (Selective Sync)
- ✅ Config files (genesis.json, permissions, etc.)
- ✅ Validator keys (preserves existing, updates if newer)
- ✅ Oracle keys
- ❌ Excludes: logs (can be regenerated)

## Sync Process

### Option 1: Automated Sync (Recommended)

```bash
cd /home/intlc/projects/proxmox
./scripts/sync-to-ml110.sh
```

This script will:
1. Create a backup of existing files
2. Remove old smom-dbis-138-proxmox directory
3. Copy all verified working files
4. Set correct permissions
5. Verify the sync

### Option 2: Manual Clean Then Sync

**Step 1: Clean old files**
```bash
./scripts/clean-ml110.sh
```

**Step 2: Sync files**
```bash
./scripts/sync-to-ml110.sh
```

### Option 3: Manual Process

**1. SSH to ml110**
```bash
ssh root@192.168.11.10
```

**2. Backup existing files**
```bash
cd /opt
BACKUP_DIR="/opt/backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BACKUP_DIR"
cp -r smom-dbis-138 "$BACKUP_DIR/" 2>/dev/null || true
cp -r smom-dbis-138-proxmox "$BACKUP_DIR/" 2>/dev/null || true
```

**3. Remove old proxmox project**
```bash
rm -rf /opt/smom-dbis-138-proxmox
```

**4. From local machine, sync files**
```bash
cd /home/intlc/projects/proxmox

# Sync proxmox project
rsync -avz --delete \
    --exclude='.git' \
    --exclude='*.log' \
    --exclude='logs/*' \
    -e "sshpass -p 'L@kers2010' ssh -o StrictHostKeyChecking=no" \
    smom-dbis-138-proxmox/ \
    root@192.168.11.10:/opt/smom-dbis-138-proxmox/

# Sync source project config and keys
rsync -avz \
    -e "sshpass -p 'L@kers2010' ssh -o StrictHostKeyChecking=no" \
    ../smom-dbis-138/config/ \
    root@192.168.11.10:/opt/smom-dbis-138/config/

rsync -avz \
    -e "sshpass -p 'L@kers2010' ssh -o StrictHostKeyChecking=no" \
    ../smom-dbis-138/keys/ \
    root@192.168.11.10:/opt/smom-dbis-138/keys/
```

## Verification

After syncing, verify files:

```bash
./scripts/verify-ml110-sync.sh
```

Or manually:

```bash
ssh root@192.168.11.10

# Check proxmox project
cd /opt/smom-dbis-138-proxmox
ls -la
cat config/proxmox.conf | grep VALIDATOR_COUNT
cat config/network.conf | grep GATEWAY

# Check source project
cd /opt/smom-dbis-138
ls -la config/
ls -la keys/validators/
```

## Important Notes

### Validator Keys
- Current state: 4 validator keys (validator-1 through validator-4)
- Expected: 5 validator keys (validator-5 missing)
- Action: Keys will be preserved. Generate validator-5 if needed.

### Configuration Files
- All config files will be updated with latest changes
- `network.conf` will use 192.168.11.X subnet
- `proxmox.conf` will have correct VMID ranges

### Scripts
- All scripts will have execute permissions set
- All scripts use updated VMID ranges and IP addresses

## Troubleshooting

### Connection Issues
```bash
# Test SSH connection
sshpass -p 'L@kers2010' ssh -o StrictHostKeyChecking=no root@192.168.11.10 "echo 'Connected'"
```

### Permission Issues
```bash
# Fix permissions on ml110
ssh root@192.168.11.10
chmod +x /opt/smom-dbis-138-proxmox/scripts/*.sh
chmod +x /opt/smom-dbis-138-proxmox/scripts/*/*.sh
chmod 600 /opt/smom-dbis-138/keys/**/*.priv
```

### Missing Files
```bash
# Re-run sync
./scripts/sync-to-ml110.sh
```

## Files Preserved

The sync process preserves:
- ✅ Existing validator keys (unless newer versions exist)
- ✅ Configuration customizations (if any)
- ✅ Backup of old files (in /opt/backup-YYYYMMDD-HHMMSS/)

## Files Updated

The sync process updates:
- ✅ All scripts with latest fixes
- ✅ All configuration files with current values
- ✅ All documentation with latest information
- ✅ Network configuration (192.168.11.X)
- ✅ VMID ranges (1000-1004, 1500-1503, 2500-2502)

## Next Steps After Sync

1. **Verify sync**: Run `./scripts/verify-ml110-sync.sh`
2. **Check configuration**: Review `config/proxmox.conf` and `config/network.conf`
3. **Generate validator-5 key** (if needed): See `docs/VALIDATOR_KEY_DETAILS.md`
4. **Deploy**: Run `./deploy-all.sh` on ml110

