# Model Dock Migration Checklist

This checklist covers migration from `/home/mark/modeldock` to `/srv/arch1/modeldock`.

## Goal

- Move the live stack root to `/srv/arch1/modeldock`
- Preserve state, receipts, registry, outputs, and config
- Avoid port conflicts and split-brain runtime between old and new roots

## Preconditions

- Privileged write access to `/srv/arch1`
- Docker engine available
- Legacy `docker-compose` available
- Enough free space under `/srv/arch1`
- A maintenance window long enough to stop compose-managed services cleanly

## Decide first

- Decide whether `n8n` stays host-side or moves into compose
- If `n8n` stays host-side, keep `127.0.0.1:5678` reserved and do not start compose `n8n`
- If `n8n` moves into compose, retire the host-side service before bringing up the compose container

## Copy plan

1. Create the target tree under `/srv/arch1/modeldock`
2. Stop compose-managed services from `/home/mark/modeldock`
3. Stop the host-side `modeldock-drive-upload.timer`
4. Copy `config`, `registry`, `receipts`, `outputs`, `portal`, `.env`, and `docker-compose.yml`
5. Copy `state/open-webui`, `state/flowise`, `state/qdrant`, `state/postgres`, and `state/redis`
6. Copy `state/n8n` only if `n8n` is moving into compose
7. Preserve file ownership and modes during the copy

## Suggested command sequence

Inspect the target and create the root:

```bash
sudo mkdir -p /srv/arch1/modeldock
sudo chown -R mark:mark /srv/arch1/modeldock
```

Stop local compose-managed services:

```bash
cd /home/mark/modeldock
docker-compose --env-file .env -f docker-compose.yml down
systemctl --user stop modeldock-drive-upload.timer
```

Copy the tree:

```bash
sudo rsync -a /home/mark/modeldock/ /srv/arch1/modeldock/
sudo chown -R mark:mark /srv/arch1/modeldock
```

Update the target env root:

```bash
sed -i 's#^MODELDOCK_ROOT=/home/mark/modeldock#MODELDOCK_ROOT=/srv/arch1/modeldock#' /srv/arch1/modeldock/.env
```

Bring the stack up from the target:

```bash
cd /srv/arch1/modeldock
./start-state-services.sh
./start-phase2-services.sh
./start-phase3-workers.sh
systemctl --user start modeldock-drive-upload.timer
```

## Verify after cutover

- `docker-compose --env-file .env -f docker-compose.yml ps` shows the expected compose-managed services
- `curl -fsS http://127.0.0.1:8080/health` returns `200`
- `curl -fsS http://127.0.0.1:4000/v1/models` returns `200`
- `python3 /srv/arch1/modeldock/config/output-sync/status.py` returns a sane summary
- `systemctl --user status modeldock-drive-upload.timer` shows active
- Open WebUI login works with the intended admin account
- Postgres auth check succeeds with the target `.env` value

## Clean up only after verification

- Keep `/home/mark/modeldock` intact until the target has passed all checks
- Repoint any helper scripts or timers that still hardcode `/home/mark/modeldock`
- Update receipts and docs to reflect the new stack root
- Archive or remove `/home/mark/modeldock` only after the new root has been stable long enough to trust
