5.3 KiB
Migration Guide: macmini3 → ingress.nixc.us
This guide explains how to migrate the haste.nixc.us services from macmini3 to ingress.nixc.us.
Prerequisites
-
SSH Access: Ensure you have SSH key-based authentication set up for both hosts:
macmini3(source)ingress.nixc.us(target)
The script uses non-interactive SSH commands like:
ssh macmini3 "command" ssh ingress.nixc.us "command" -
Docker Swarm: Both hosts should be part of the same Docker Swarm cluster, or you need to deploy to the target's Swarm manager.
-
Volume Access: The script needs to access Docker volumes on both hosts.
Migration Steps
Option 1: Automated Migration (Recommended)
Run the full migration script which handles everything:
./migrate-to-ingress.sh
The script will:
- Verify SSH connectivity to both hosts
- Backup Docker volumes (
redis_dataandpublic_system) from macmini3 - Transfer backups to ingress.nixc.us
- Restore volumes on ingress.nixc.us
- Update
stack.production.ymlto use the new hostname - Deploy the stack to the new location
- Verify the deployment
- Clean up temporary files
Option 2: Manual Migration
If you prefer to migrate manually or need more control:
Step 1: Update Stack Configuration
# Auto-detect hostname
./update-stack-hostname.sh
# Or specify hostname explicitly
./update-stack-hostname.sh ingress
Step 2: Backup Volumes from macmini3
BACKUP_DIR="/tmp/haste-migration-$(date +%Y%m%d-%H%M%S)"
ssh macmini3 "mkdir -p ${BACKUP_DIR}"
# Backup redis_data
ssh macmini3 "docker run --rm -v haste_redis_data:/source:ro -v ${BACKUP_DIR}:/backup alpine:latest tar czf /backup/redis_data.tar.gz -C /source ."
# Backup public_system
ssh macmini3 "docker run --rm -v haste_public_system:/source:ro -v ${BACKUP_DIR}:/backup alpine:latest tar czf /backup/public_system.tar.gz -C /source ."
Step 3: Transfer Backups
ssh ingress.nixc.us "mkdir -p ${BACKUP_DIR}"
scp macmini3:${BACKUP_DIR}/*.tar.gz ingress.nixc.us:${BACKUP_DIR}/
Step 4: Restore Volumes on ingress.nixc.us
# Create volumes
ssh ingress.nixc.us "docker volume create haste_redis_data"
ssh ingress.nixc.us "docker volume create haste_public_system"
# Restore redis_data
ssh ingress.nixc.us "docker run --rm -v haste_redis_data:/target -v ${BACKUP_DIR}:/backup alpine:latest sh -c 'rm -rf /target/* && tar xzf /backup/redis_data.tar.gz -C /target'"
# Restore public_system
ssh ingress.nixc.us "docker run --rm -v haste_public_system:/target -v ${BACKUP_DIR}:/backup alpine:latest sh -c 'rm -rf /target/* && tar xzf /backup/public_system.tar.gz -C /target'"
Step 5: Deploy Updated Stack
scp stack.production.yml ingress.nixc.us:/tmp/
ssh ingress.nixc.us "docker stack deploy --with-registry-auth -c /tmp/stack.production.yml haste"
Step 6: Verify Deployment
ssh ingress.nixc.us "docker stack services haste"
Step 7: Test Service
Visit https://haste.nixc.us and verify it's working correctly.
Step 8: Cleanup Old Deployment (when ready)
ssh macmini3 "docker stack rm haste"
ssh macmini3 "docker volume rm haste_redis_data haste_public_system"
Configuration
The migration script supports environment variables for customization:
# Customize source/target hosts
SOURCE_HOST=macmini3 TARGET_HOST=ingress.nixc.us ./migrate-to-ingress.sh
# Customize stack name (default: haste)
STACK_NAME=haste-production ./migrate-to-ingress.sh
# Specify target hostname explicitly
TARGET_HOSTNAME=ingress ./migrate-to-ingress.sh
# Enable automatic cleanup of old deployment
CLEANUP_OLD=true ./migrate-to-ingress.sh
Troubleshooting
SSH Connection Issues
If you get SSH connection errors:
- Ensure SSH keys are set up:
ssh-copy-id user@macmini3andssh-copy-id user@ingress.nixc.us - Test connectivity:
ssh macmini3 "echo OK"andssh ingress.nixc.us "echo OK" - The script uses
-o BatchMode=yesfor non-interactive SSH, which requires key-based auth (no password prompts)
Volume Not Found
If volumes are not found, check the actual volume names:
ssh macmini3 "docker volume ls | grep haste"
Docker Swarm prefixes volumes with the stack name, so redis_data becomes haste_redis_data if the stack is named haste.
Hostname Detection
The script auto-detects the target hostname. If it's incorrect, specify it explicitly:
TARGET_HOSTNAME=ingress ./migrate-to-ingress.sh
Stack Deployment Issues
If deployment fails, check:
- Docker Swarm is initialized on the target
- You have access to the Swarm manager
- Registry authentication is set up
Rollback
If something goes wrong, you can rollback:
-
Restore the original stack file:
mv stack.production.yml.bak stack.production.yml -
Redeploy to macmini3:
ssh macmini3 "docker stack deploy --with-registry-auth -c stack.production.yml haste" -
Remove volumes from ingress.nixc.us if needed:
ssh ingress.nixc.us "docker volume rm haste_redis_data haste_public_system"
Notes
- The migration script creates backups before making changes
- Original
stack.production.ymlis backed up with.bakextension - Temporary backup files are cleaned up automatically
- Old deployment on macmini3 is NOT removed automatically (set
CLEANUP_OLD=trueto enable)