3.2 KiB
3.2 KiB
Rollback Procedure — ERP Nutzfahrzeuge
Rollback Strategy
The rollback strategy depends on the deployment method used.
Coolify Rollback
Option A: Redeploy Previous Image
- In Coolify, navigate to the resource
- Go to Deployments tab
- Find the last known-good deployment
- Click Redeploy on that deployment
- Wait for health check to pass
- Verify endpoints:
GET /api/v1/health→ 200GET /→ 200
Option B: Rollback via Git
- In the repository, identify the last known-good commit:
git log --oneline -10 - Revert to the previous commit:
git revert <commit_hash> # or git reset --hard <commit_hash> git push origin main - Trigger a new deployment in Coolify (auto-deploy or manual)
- Wait for health check to pass
Docker Compose Rollback
Step 1: Stop Current Deployment
docker-compose down
Step 2: Revert Code
git checkout <last-known-good-tag-or-commit>
Step 3: Rebuild and Restart
docker-compose build
docker-compose up -d
Step 4: Verify
curl -s http://localhost:8000/api/v1/health
docker-compose logs --tail 50 backend
Database Rollback
If Alembic migrations are used:
cd backend
/opt/venv/bin/python -m alembic downgrade -1 # rollback one revision
# or
/opt/venv/bin/python -m alembic downgrade <revision_id> # rollback to specific revision
If no migration tool:
- Database schema changes are applied on app startup via SQLAlchemy
create_all - Rollback requires manual SQL or restoring from a database backup
- Always take a database backup before deployment:
pg_dump -U erp_user erp_test > backup_$(date +%Y%m%d_%H%M%S).sql
Restore from backup:
psql -U erp_user erp_test < backup_YYYYMMDD_HHMMSS.sql
Rollback Decision Tree
| Situation | Action |
|---|---|
| App won't start after deploy | Redeploy previous image (Coolify) or git checkout + rebuild (Docker) |
| Health check fails | Redeploy previous image; check DB connectivity |
| Database migration broke schema | alembic downgrade or restore from pg_dump backup |
| Frontend broken | Rebuild frontend from previous commit; redeploy |
| Performance regression | Redeploy previous image; investigate in staging |
| Security issue found | Rollback immediately; patch in staging; redeploy |
Post-Rollback Verification
After any rollback:
- ✅ Health check passes:
GET /api/v1/health→ 200{"status":"ok"} - ✅ Root endpoint:
GET /→ 200 - ✅ Login works:
POST /api/v1/auth/login→ 200 with valid credentials - ✅ No errors in logs:
docker logs <container> --tail 50 - ✅ Frontend loads at production URL
- ✅ Database queries return expected data
Emergency Rollback (Quick)
If the deployment is causing immediate issues:
# Coolify: use the Redeploy button on the last good deployment
# Docker Compose:
docker-compose down
git checkout <last-good-commit>
docker-compose build && docker-compose up -d
curl -s http://localhost:8000/api/v1/health
Time to rollback: < 5 minutes (if image is cached) or < 15 minutes (if rebuild needed).