deployment-rollback
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDeployment Rollback Skill
部署回滚Skill
Quick Rollback via Vercel
通过Vercel快速回滚
Using Vercel Dashboard
使用Vercel控制台
- Go to Vercel Dashboard → Project → Deployments
- Find the previous working deployment
- Click the three dots menu → "Promote to Production"
- 进入Vercel控制台 → 项目 → 部署记录
- 找到之前可正常运行的部署版本
- 点击三点菜单 → "Promote to Production(推广至生产环境)"
Using Vercel CLI
使用Vercel CLI
bash
undefinedbash
undefinedList recent deployments
列出近期部署记录
vercel list
vercel list
Promote a specific deployment to production
将指定部署版本推广至生产环境
vercel promote <deployment-url>
vercel promote <deployment-url>
Or rollback to previous production deployment
或回滚至之前的生产环境部署版本
vercel rollback
undefinedvercel rollback
undefinedDatabase Rollback
数据库回滚
bash
undefinedbash
undefinedRollback last migration
回滚上一次迁移
pnpm -F @sgcarstrends/database db:rollback
pnpm -F @sgcarstrends/database db:rollback
Rollback to specific migration
回滚至指定迁移版本
pnpm -F @sgcarstrends/database db:rollback --to 20240115_initial
pnpm -F @sgcarstrends/database db:rollback --to 20240115_initial
Restore from backup
从备份恢复
pg_dump $DATABASE_URL > backup-pre-deploy.sql # Before deploy
psql $DATABASE_URL < backup-pre-deploy.sql # Restore if needed
undefinedpg_dump $DATABASE_URL > backup-pre-deploy.sql # 部署前执行
psql $DATABASE_URL < backup-pre-deploy.sql # 必要时恢复
undefinedGit-Based Rollback
基于Git的回滚
bash
undefinedbash
undefinedRevert specific commit
撤销指定提交
git revert <commit-hash>
git push origin main # Triggers Vercel redeploy
git revert <commit-hash>
git push origin main # 触发Vercel重新部署
Create rollback branch
创建回滚分支
git checkout -b rollback/v1.1.0
git reset --hard v1.1.0
git push origin rollback/v1.1.0
gh pr create --title "Rollback to v1.1.0" --body "Emergency rollback"
undefinedgit checkout -b rollback/v1.1.0
git reset --hard v1.1.0
git push origin rollback/v1.1.0
gh pr create --title "Rollback to v1.1.0" --body "Emergency rollback"
undefinedCache Invalidation
缓存失效处理
bash
undefinedbash
undefinedRevalidate Next.js cache
重新验证Next.js缓存
Clear Redis cache
清空Redis缓存
redis-cli -h $REDIS_HOST FLUSHALL
undefinedredis-cli -h $REDIS_HOST FLUSHALL
undefinedHealth Checks During Rollback
回滚期间的健康检查
bash
curl -f https://sgcarstrends.com || echo "Web unhealthy"
psql $DATABASE_URL -c "SELECT 1" || echo "Database unreachable"bash
curl -f https://sgcarstrends.com || echo "Web unhealthy"
psql $DATABASE_URL -c "SELECT 1" || echo "Database unreachable"Rollback Checklist
回滚检查清单
Pre-Rollback:
- Identify issue and severity
- Determine scope (full/partial)
- Check backup availability
- Notify team
During:
- Rollback via Vercel dashboard or CLI
- Rollback database if needed
- Clear caches
- Verify health checks
- Run smoke tests
Post:
- Monitor error rates in Vercel dashboard
- Verify functionality restored
- Document what happened
- Create postmortem
回滚前:
- 确定问题及严重程度
- 确定影响范围(完全/部分)
- 检查备份是否可用
- 通知团队成员
回滚中:
- 通过Vercel控制台或CLI执行回滚
- 必要时回滚数据库
- 清空缓存
- 验证健康检查结果
- 运行冒烟测试
回滚后:
- 在Vercel控制台监控错误率
- 验证功能是否恢复正常
- 记录事件详情
- 编写事后分析报告
Common Scenarios
常见场景
Critical Bug:
bash
vercel rollback
curl https://sgcarstrends.com/api/healthDatabase Migration Failure:
bash
pnpm -F @sgcarstrends/database db:rollback
git revert HEAD
git push origin main严重漏洞:
bash
vercel rollback
curl https://sgcarstrends.com/api/health数据库迁移失败:
bash
pnpm -F @sgcarstrends/database db:rollback
git revert HEAD
git push origin mainTroubleshooting
问题排查
Rollback deployment not working:
bash
undefined部署回滚失败:
bash
undefinedForce redeploy from known good commit
从已知正常的提交强制重新部署
git checkout v1.1.0
vercel --prod
**Database schema mismatch:**
```bash
pnpm -F @sgcarstrends/database db:rollbackgit checkout v1.1.0
vercel --prod
**数据库架构不匹配:**
```bash
pnpm -F @sgcarstrends/database db:rollbackOr restore backup: psql $DATABASE_URL < backup-pre-deploy.sql
或恢复备份:psql $DATABASE_URL < backup-pre-deploy.sql
undefinedundefinedBest Practices
最佳实践
- Always Backup: Create database backups before major deployments
- Test Rollback: Practice rollback procedures in preview deployments
- Feature Flags: Use for quick feature disabling without rollback
- Monitor Closely: Watch Vercel analytics during and after rollback
- Document Everything: Record what happened and why
- 始终备份:在重大部署前创建数据库备份
- 测试回滚:在预览部署环境中演练回滚流程
- 功能开关:使用功能开关快速禁用功能,无需执行回滚
- 密切监控:回滚期间及之后关注Vercel分析数据
- 完整记录:记录事件发生的经过及原因
References
参考资料
- Vercel Rollbacks: https://vercel.com/docs/deployments/rollbacks
- See skill for debugging issues
monitoring
- Vercel回滚文档:https://vercel.com/docs/deployments/rollbacks
- 调试问题请参考skill
monitoring