diff --git a/code/websites/pokedex.online/DEPLOYMENT.md b/code/websites/pokedex.online/DEPLOYMENT.md index 99f505d..393bb89 100644 --- a/code/websites/pokedex.online/DEPLOYMENT.md +++ b/code/websites/pokedex.online/DEPLOYMENT.md @@ -177,7 +177,7 @@ docker compose logs ### Port Already in Use ```bash # Use different port -npm run deploy:pokedex -- --port 8081 --backend-port 3001 +./deploy.sh --target internal --port 8081 --backend-port 3001 ``` ### Backend Can't Connect to Frontend @@ -185,6 +185,91 @@ npm run deploy:pokedex -- --port 8081 --backend-port 3001 - Verify backend container is on same Docker network - Check backend service name in nginx config matches compose file +## Rollback + +### Automated Backups + +The deploy script creates timestamped backups before each deployment in `backups/`: + +```bash +# List available backups +ls -lh backups/ + +# Example: +# backup_20240115_143022.tar.gz (5.2M) +# backup_20240115_151534.tar.gz (5.3M) +``` + +The script automatically keeps only the last 5 backups to save space. + +### Rollback Procedure + +**1. Stop Current Deployment** +```bash +ssh GregRJacobs@10.0.0.81 -p 2323 +cd /volume1/docker/pokedex.online +docker compose down +``` + +**2. Restore from Backup (Local)** +```bash +# Extract backup to temporary directory +mkdir /tmp/restore +tar -xzf backups/backup_TIMESTAMP.tar.gz -C /tmp/restore + +# Copy files back +rsync -av /tmp/restore/ ./ +``` + +**3. Redeploy** +```bash +./deploy.sh --skip-tests --target internal +``` + +### Quick Restart + +If you just need to restart existing containers without code changes: + +```bash +# On the server +cd /volume1/docker/pokedex.online +docker compose restart +``` + +### Git-Based Rollback + +Roll back to a previous commit: + +```bash +# Find commit to rollback to +git log --oneline -n 10 + +# Checkout previous version +git checkout + +# Redeploy +./deploy.sh --target internal + +# Return to main branch when done +git checkout main +``` + +### Emergency Rollback + +If deployment completely fails and you need to restore quickly: + +```bash +# Stop failed deployment +ssh GregRJacobs@10.0.0.81 -p 2323 "cd /volume1/docker/pokedex.online && docker compose down" + +# Extract most recent backup directly on server +LATEST_BACKUP=$(ls -t backups/backup_*.tar.gz | head -1) +ssh GregRJacobs@10.0.0.81 -p 2323 "cd /volume1/docker/pokedex.online && tar -xzf /path/to/backup" + +# Restart containers +ssh GregRJacobs@10.0.0.81 -p 2323 "cd /volume1/docker/pokedex.online && docker compose up -d" +``` + ## URLs After Deployment ### Internal Network