pre migrate
This commit is contained in:
parent
a52b5e23b1
commit
d220d2f034
3 changed files with 420 additions and 0 deletions
221
MIGRATION.md
Normal file
221
MIGRATION.md
Normal file
|
|
@ -0,0 +1,221 @@
|
||||||
|
# Migration Guide: Dev Mac → Production Mac
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Migrate the entire Studio EinsZwoVier web application from development Mac (`einszwovier.local`) to production Mac (`admin@124.local`) using SCP carbon copy method.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- SSH access to production Mac: Configure SSH shortcut for easy access
|
||||||
|
- Both Macs on same network
|
||||||
|
- Docker Desktop installed on production Mac (124.local)
|
||||||
|
- Git configured on production Mac
|
||||||
|
|
||||||
|
### Configure SSH Access (Recommended)
|
||||||
|
|
||||||
|
Add to `~/.ssh/config` on dev Mac:
|
||||||
|
|
||||||
|
```ssh-config
|
||||||
|
Host 124
|
||||||
|
HostName 124.local
|
||||||
|
User admin
|
||||||
|
ForwardAgent yes
|
||||||
|
```
|
||||||
|
|
||||||
|
Then test: `ssh 124 "echo 'Connection works!'"`
|
||||||
|
|
||||||
|
## Migration Steps
|
||||||
|
|
||||||
|
### 1. Push Latest Changes (on dev Mac)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /Users/aron124/webapp_124
|
||||||
|
git push forgejo main
|
||||||
|
git push origin main # optional: backup to GitHub
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Stop All Services (on dev Mac)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /Users/aron124/webapp_124
|
||||||
|
docker compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
**Verify all stopped:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose ps # should show nothing running
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Copy Everything to Production Mac
|
||||||
|
|
||||||
|
**On production Mac (124.local), run:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Create parent directory if needed
|
||||||
|
mkdir -p /Users/admin
|
||||||
|
|
||||||
|
# SCP entire project (this will take a while - includes all Docker volumes)
|
||||||
|
scp -r aron124@einszwovier.local:/Users/aron124/webapp_124 /Users/admin/
|
||||||
|
|
||||||
|
# Estimated transfer time: 5-30 minutes depending on:
|
||||||
|
# - Ollama models size (~several GB)
|
||||||
|
# - Matrix message history
|
||||||
|
# - BookStack content
|
||||||
|
# - LLM cache
|
||||||
|
```
|
||||||
|
|
||||||
|
**What gets copied:**
|
||||||
|
|
||||||
|
- ✅ All source code and git history
|
||||||
|
- ✅ `.env` file with credentials
|
||||||
|
- ✅ Matrix database & message history (`matrix/data/`)
|
||||||
|
- ✅ Ollama LLM models (`ollama/`)
|
||||||
|
- ✅ Open WebUI data (`open-webui/`)
|
||||||
|
- ✅ BookStack content & database (`bookstack/`)
|
||||||
|
- ✅ Docmost database (`docmost/`)
|
||||||
|
- ✅ User uploads (`data/uploads/`)
|
||||||
|
- ✅ Docker Compose configuration
|
||||||
|
|
||||||
|
### 4. Fix File Permissions (on production Mac)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /Users/admin/webapp_124
|
||||||
|
|
||||||
|
# Ensure you own all files
|
||||||
|
sudo chown -R $(whoami):staff .
|
||||||
|
|
||||||
|
# Fix Docker volume permissions if needed
|
||||||
|
chmod -R 755 matrix/ ollama/ open-webui/ bookstack/ docmost/ data/
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Start Services (on production Mac)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /Users/admin/webapp_124
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6. Verify Everything Works
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check all services are running
|
||||||
|
docker compose ps
|
||||||
|
|
||||||
|
# Check health status (wait ~30 seconds for health checks)
|
||||||
|
docker compose ps | grep -i healthy
|
||||||
|
|
||||||
|
# Check logs for errors
|
||||||
|
docker compose logs --tail=50
|
||||||
|
|
||||||
|
# Test web interface
|
||||||
|
open http://localhost
|
||||||
|
# or http://einszwovier.local (if DNS is set up)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 7. Restart Dev Mac Services (optional)
|
||||||
|
|
||||||
|
If you want to keep dev Mac running alongside:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# On dev Mac
|
||||||
|
cd /Users/aron124/webapp_124
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** Both will share same Matrix homeserver name - you may need to:
|
||||||
|
|
||||||
|
- Change `server_name` in `matrix/data/homeserver.yaml` on one instance
|
||||||
|
- Use different external ports in `docker-compose.yml`
|
||||||
|
|
||||||
|
## Verification Checklist
|
||||||
|
|
||||||
|
- [ ] All 11 services show as "healthy" in `docker compose ps`
|
||||||
|
- [ ] Web interface accessible at <http://localhost> or <http://einszwovier.local>
|
||||||
|
- [ ] Cost calculator can analyze PDFs
|
||||||
|
- [ ] Matrix integration works (submit test order)
|
||||||
|
- [ ] BookStack accessible at configured port
|
||||||
|
- [ ] Open WebUI (LLM chat) accessible
|
||||||
|
- [ ] JupyterHub accessible and courses load
|
||||||
|
- [ ] Forgejo instance accessible
|
||||||
|
- [ ] Element Web (Matrix client) accessible
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Services won't start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check logs
|
||||||
|
docker compose logs [service-name]
|
||||||
|
|
||||||
|
# Common issues:
|
||||||
|
# - Port conflicts: Change ports in docker-compose.yml
|
||||||
|
# - Permission errors: Run chown command again
|
||||||
|
# - Volume corruption: May need to delete and recreate volumes
|
||||||
|
```
|
||||||
|
|
||||||
|
### Matrix won't connect
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check Matrix logs
|
||||||
|
docker compose logs synapse
|
||||||
|
|
||||||
|
# Verify environment variables
|
||||||
|
cat .env | grep MATRIX
|
||||||
|
|
||||||
|
# Test Matrix health endpoint
|
||||||
|
curl http://localhost:8008/_matrix/client/versions
|
||||||
|
```
|
||||||
|
|
||||||
|
### Git issues
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Verify remotes still work
|
||||||
|
git remote -v
|
||||||
|
git fetch forgejo
|
||||||
|
|
||||||
|
# If needed, reconfigure
|
||||||
|
git remote set-url forgejo https://forgejo.petau.net/aron/124-webapp.git
|
||||||
|
```
|
||||||
|
|
||||||
|
## Rollback Plan
|
||||||
|
|
||||||
|
If migration fails, dev Mac (`einszwovier.local`) still has everything:
|
||||||
|
|
||||||
|
1. Stop services on production Mac: `docker compose down`
|
||||||
|
2. Restart on dev Mac: `docker compose up -d`
|
||||||
|
3. Debug issue before retrying migration
|
||||||
|
|
||||||
|
## Post-Migration Cleanup (optional)
|
||||||
|
|
||||||
|
After confirming production Mac works for 1-2 weeks:
|
||||||
|
|
||||||
|
**On dev Mac:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /Users/aron124/webapp_124
|
||||||
|
docker compose down -v # removes volumes too
|
||||||
|
cd ..
|
||||||
|
rm -rf webapp_124 # or keep as backup
|
||||||
|
```
|
||||||
|
|
||||||
|
## Network Configuration
|
||||||
|
|
||||||
|
Both Macs are on `einszwovier.local` domain. You may want to:
|
||||||
|
|
||||||
|
- Update DNS to point `einszwovier.local` → production Mac IP
|
||||||
|
- Configure nginx reverse proxy for external access
|
||||||
|
- Set up SSL certificates for HTTPS
|
||||||
|
- Configure firewall rules
|
||||||
|
|
||||||
|
## Data That Won't Transfer (if using git clone method)
|
||||||
|
|
||||||
|
If you later need to do a clean migration via git clone instead:
|
||||||
|
|
||||||
|
- Matrix message history (excluded in `.gitignore`)
|
||||||
|
- Matrix signing keys (will regenerate)
|
||||||
|
- Ollama models (need to re-download)
|
||||||
|
- BookStack uploads/database (excluded in `.gitignore`)
|
||||||
|
- User uploaded PDFs (excluded in `.gitignore`)
|
||||||
|
|
||||||
|
**But with SCP method, ALL of this transfers! ✅**
|
||||||
105
MIGRATION_QUICKSTART.md
Normal file
105
MIGRATION_QUICKSTART.md
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
# Quick Migration Guide
|
||||||
|
|
||||||
|
## Prerequisites - SSH Setup
|
||||||
|
|
||||||
|
Add to `~/.ssh/config`:
|
||||||
|
|
||||||
|
```ssh-config
|
||||||
|
Host 124
|
||||||
|
HostName 124.local
|
||||||
|
User admin
|
||||||
|
ForwardAgent yes
|
||||||
|
```
|
||||||
|
|
||||||
|
Test: `ssh 124 "echo works"`
|
||||||
|
|
||||||
|
## TL;DR - Run from Dev Mac (einszwovier.local)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Run this script from your dev Mac
|
||||||
|
cd /Users/aron124/webapp_124
|
||||||
|
./migrate_to_production.sh
|
||||||
|
|
||||||
|
# That's it! The script handles everything.
|
||||||
|
```
|
||||||
|
|
||||||
|
## What the Script Does
|
||||||
|
|
||||||
|
1. ✅ Stops Docker services on dev Mac (locally)
|
||||||
|
2. ✅ Creates directory on production Mac via SSH
|
||||||
|
3. ✅ Copies all files using rsync (with progress bar)
|
||||||
|
4. ✅ Fixes permissions on production Mac via SSH
|
||||||
|
5. ✅ Starts all services on production Mac via SSH
|
||||||
|
6. ✅ Shows service status
|
||||||
|
|
||||||
|
## Manual Steps (if you prefer)
|
||||||
|
|
||||||
|
### On Dev Mac (einszwovier.local)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Stop services
|
||||||
|
cd /Users/aron124/webapp_124
|
||||||
|
docker compose down
|
||||||
|
|
||||||
|
# Copy everything to production
|
||||||
|
rsync -avz --progress /Users/aron124/webapp_124/ 124:/Users/admin/webapp_124/
|
||||||
|
```
|
||||||
|
|
||||||
|
### On Production Mac (124.local)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# SSH into production
|
||||||
|
ssh 124
|
||||||
|
# Fix permissions
|
||||||
|
cd /Users/admin/webapp_124
|
||||||
|
sudo chown -R admin:staff .
|
||||||
|
chmod -R 755 matrix/ ollama/ open-webui/ bookstack/ docmost/ data/
|
||||||
|
|
||||||
|
# Start services
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# Check status
|
||||||
|
docker compose ps
|
||||||
|
```
|
||||||
|
|
||||||
|
## Access Points After Migration
|
||||||
|
|
||||||
|
- **Main App**: <http://124.local> or <http://localhost> (on production Mac)
|
||||||
|
- **Matrix**: <http://124.local:8008>
|
||||||
|
- **BookStack**: <http://124.local:6875>
|
||||||
|
- **Open WebUI**: <http://124.local:8080>
|
||||||
|
- **JupyterHub**: <http://124.local:8000>
|
||||||
|
- **Forgejo**: <http://124.local:3000>
|
||||||
|
- **Element Web**: <http://124.local:8888>
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
**SSH issues:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Test SSH connection first
|
||||||
|
ssh 124 "echo 'Connection works!'"
|
||||||
|
|
||||||
|
# If you need password-less SSH (recommended):
|
||||||
|
ssh-copy-id 124
|
||||||
|
```
|
||||||
|
|
||||||
|
**Permission issues:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# On production Mac
|
||||||
|
cd /Users/admin/webapp_124
|
||||||
|
sudo chown -R admin:staff .
|
||||||
|
```
|
||||||
|
|
||||||
|
**Services won't start:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# On production Mac
|
||||||
|
cd /Users/admin/webapp_124
|
||||||
|
docker compose logs [service-name]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Full Documentation
|
||||||
|
|
||||||
|
See `MIGRATION.md` for complete step-by-step guide.
|
||||||
94
migrate_to_production.sh
Executable file
94
migrate_to_production.sh
Executable file
|
|
@ -0,0 +1,94 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Studio EinsZwoVier - Production Migration Script
|
||||||
|
# Run this FROM the dev Mac (einszwovier.local) to migrate to production Mac (124.local)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # Exit on any error
|
||||||
|
|
||||||
|
echo "════════════════════════════════════════════════════════════════"
|
||||||
|
echo " Studio EinsZwoVier - Production Migration Script"
|
||||||
|
echo "════════════════════════════════════════════════════════════════"
|
||||||
|
echo ""
|
||||||
|
echo "This will copy the entire webapp from THIS machine to admin@124.local"
|
||||||
|
echo ""
|
||||||
|
echo "Prerequisites:"
|
||||||
|
echo " - You're running this ON the dev Mac (einszwovier.local)"
|
||||||
|
echo " - You have SSH access to 124.local (configured as 'ssh 124')"
|
||||||
|
echo " - Docker Desktop is installed on production Mac (124.local)"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
read -p "Ready to proceed? (y/n) " -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
echo "Migration cancelled."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
PROD_MAC="124" # SSH config alias for admin@124.local
|
||||||
|
DEV_PATH="/Users/aron124/webapp_124"
|
||||||
|
PROD_PATH="/Users/admin/webapp_124"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "═══ Step 1: Stop services on dev Mac (locally) ═══"
|
||||||
|
cd "$DEV_PATH"
|
||||||
|
docker compose down
|
||||||
|
echo "✅ Services stopped"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "═══ Step 2: Create directory structure on production Mac ═══"
|
||||||
|
ssh "$PROD_MAC" "mkdir -p $(dirname "$PROD_PATH")"
|
||||||
|
echo "✅ Directory created"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "═══ Step 3: Copy all files (this may take 10-30 minutes) ═══"
|
||||||
|
echo "Copying from: $DEV_PATH (local)"
|
||||||
|
echo "Copying to: $PROD_MAC:$PROD_PATH"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Use rsync for better progress and resume capability
|
||||||
|
if command -v rsync &> /dev/null; then
|
||||||
|
rsync -avz --progress "$DEV_PATH/" "$PROD_MAC:$PROD_PATH/"
|
||||||
|
else
|
||||||
|
# Fallback to scp
|
||||||
|
scp -r "$DEV_PATH" "$PROD_MAC:$(dirname "$PROD_PATH")/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ Files copied successfully"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "═══ Step 4: Fix file permissions on production Mac ═══"
|
||||||
|
ssh "$PROD_MAC" "sudo chown -R \$(whoami):staff '$PROD_PATH' && chmod -R 755 '$PROD_PATH/matrix' '$PROD_PATH/ollama' '$PROD_PATH/open-webui' '$PROD_PATH/bookstack' '$PROD_PATH/docmost' '$PROD_PATH/data' 2>/dev/null || true"
|
||||||
|
echo "✅ Permissions fixed"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "═══ Step 5: Start services on production Mac ═══"
|
||||||
|
ssh "$PROD_MAC" "cd '$PROD_PATH' && docker compose up -d"
|
||||||
|
|
||||||
|
echo "✅ Services starting..."
|
||||||
|
echo ""
|
||||||
|
echo "Waiting 30 seconds for services to initialize..."
|
||||||
|
sleep 30
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "═══ Step 6: Check service status ═══"
|
||||||
|
ssh "$PROD_MAC" "cd '$PROD_PATH' && docker compose ps"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "════════════════════════════════════════════════════════════════"
|
||||||
|
echo " Migration Complete!"
|
||||||
|
echo "════════════════════════════════════════════════════════════════"
|
||||||
|
echo ""
|
||||||
|
echo "Next steps:"
|
||||||
|
echo " 1. Verify services are healthy: ssh 124 'cd /Users/admin/webapp_124 && docker compose ps'"
|
||||||
|
echo " 2. Check logs if issues: ssh 124 'cd /Users/admin/webapp_124 && docker compose logs [service-name]'"
|
||||||
|
echo " 3. Test web interface: http://124.local"
|
||||||
|
echo " 4. Test cost calculator with a PDF upload"
|
||||||
|
echo " 5. Verify Matrix integration works"
|
||||||
|
echo ""
|
||||||
|
echo "To restart dev Mac services (this machine):"
|
||||||
|
echo " cd $DEV_PATH && docker compose up -d"
|
||||||
|
echo ""
|
||||||
|
echo "Full migration guide: $DEV_PATH/MIGRATION.md"
|
||||||
|
echo "════════════════════════════════════════════════════════════════"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue