Rollback and Recovery
Learn how to roll back to a previous deployment in Devpilot, understand what happens during a rollback, and follow best practices for recovering from deployment issues.
Rollback and Recovery
Sometimes a deployment introduces a bug, a performance regression, or an unexpected error that you need to resolve immediately. Rolling back restores a previous working version of your application while you investigate and fix the issue. Devpilot makes rollback a guided operation that redeploys a known-good release and tracks the full rollback history.
What is a rollback
A rollback in Devpilot creates a new deployment that uses the commit from a previous successful deployment. When you roll back, Devpilot does not reverse the lifecycle of the failed deployment — it runs a full new deployment using the target commit. This means all your current hooks execute again, ensuring the application is built and activated through the same pipeline as any other deployment.
The key difference between a rollback and a normal deployment is the source: a normal deployment pulls the latest commit on a branch, while a rollback targets a specific earlier deployment's commit.
When to use rollback
Rollback is the right choice when:
- A deployment introduces a critical bug that affects users and you need to restore service immediately. Rollback puts the previous working version back in front of users while you fix the underlying issue.
- Performance degrades after a deployment. Rolling back eliminates the new code as a variable so you can investigate.
- A dependency update breaks your application. Rolling back returns you to the version that worked with the previous dependency state.
- A configuration change breaks the deployment. Rolling back restores the previous pipeline output.
Rollback restores your application code to a previous commit. It does not revert changes in external systems such as databases, third-party APIs, or DNS records. If your deployment included database migrations, see Handling database migrations during rollback.
Rollback recommendations
Devpilot can recommend a rollback automatically for a failed deployment. When a recommendation exists, it records:
- The source deployment (the failed deployment being rolled back from).
- The target deployment (the known-good deployment Devpilot suggests rolling back to).
- An AI recommendation explaining why this target was chosen.
- A confidence score for the recommendation.
- A health check result describing the state of the target when the recommendation was generated.
Rollback recommendations move through these states:
| State | Meaning |
|---|---|
recommended | Devpilot has produced a rollback suggestion for a failed deployment. You can review and either execute or dismiss it. |
executing | A rollback has been initiated and the new rollback deployment is running. |
completed | The rollback deployment finished successfully. |
dismissed | You chose not to execute the recommendation. |
Open the failed deployment and check the rollback panel to see whether a recommendation is available.
How to perform a rollback
Open the source deployment
Navigate to your application and open the failed deployment you want to roll back from.
Review the recommendation (if present)
If Devpilot has a recommended rollback, review the suggested target, the AI explanation, and the confidence score. You can either execute the recommendation or dismiss it and choose a different target yourself.
Select a target deployment
If there is no automatic recommendation, or you want to override it, pick a target deployment — a previous Completed deployment that was previously Live. Confirm the commit hash and message are what you expect.
Execute the rollback
Initiate the rollback. You can add a short reason (for example, "Reverting after 500 error spike") that is recorded in the rollback history. Devpilot marks the rollback record as executing and creates a new deployment targeting the chosen commit.
Monitor the rollback deployment
The new rollback deployment runs through all five lifecycle stages — Pre Execution, Pre Source Control, Post Source Control, Post Setup, and Post Release — using your current hook configuration. Monitor it in real time the same way you monitor any other deployment.
The rollback deployment links back to the source failed deployment so the history is traceable.
Verify the rollback
Once the rollback deployment reaches Completed and is marked Live, verify your application is healthy:
- Check that the application responds to requests.
- Verify the issue that prompted the rollback is gone.
- Review logs for remaining errors.
The rollback history entry moves to completed.
What happens during a rollback
When you execute a rollback, Devpilot:
- Creates a rollback history record. This record ties together the source deployment (what failed), the target deployment (what you want to get back to), the rollback deployment (the new deployment that was created), the reason, and who initiated it.
- Creates a new deployment using the target deployment's commit, provider, repository, and branch.
- Runs your current deployment hooks through all five stages. Dependencies are reinstalled, build commands run, and any post-release hooks execute.
- Marks the new rollback deployment Live when it completes successfully, replacing the previous live release.
A rollback runs your current hook configuration, not the hooks from the original deployment. If you changed your hooks alongside the code that caused the issue, review your hooks to make sure they are still compatible with the older code before rolling back.
Handling database migrations during rollback
Database migrations are a common source of complexity during rollbacks. When a deployment runs migrations that alter your schema, rolling back the application code does not automatically undo those schema changes.
Consider these strategies:
- Write reversible migrations. Include a "down" method in every migration so you can undo it manually via the Web Terminal before rolling back.
- Make migrations backward-compatible. Design migrations so the previous version of the application still works with the new schema. For example, add new columns as nullable and avoid renaming or dropping columns in the same deployment that starts using them.
- Separate migration deployments. Deploy migrations independently from code that depends on them. Verify the migration first, then deploy the code. If the code deployment fails, the migration is already in place and does not need to be reverted.
Recovery best practices
Act quickly
When you identify a problem, execute the rollback rather than debugging on the live server. Getting a working version in front of users is the priority; you can investigate afterward using the failed deployment's logs and AI diagnosis.
Know your rollback target
Track which deployment is known-good. The deployment history makes this visible — the most recent Completed deployment that was previously Live is usually your target. When Devpilot has generated a rollback recommendation, it picks this target for you.
Test rollbacks before you need them
Run a rollback in a staging environment to verify the process works end-to-end with your current hook configuration. This confirms compatibility between older code and the current pipeline.
Keep enough releases
Devpilot keeps a configurable number of recent releases. If you only keep two, you can only roll back one deployment. Configure a retention that matches how far back you might realistically need to roll back.
Record a reason
Enter a clear rollback reason. It is stored on the rollback history record and shows up in audit trails and the failed deployment's diagnosis view.
Diagnose after recovery
After rolling back, run Deployment Diagnosis on the failed source deployment. The AI analysis categorizes the failure (for example, dependency failure, Git failure, or configuration error) and suggests fixes to apply before your next deployment.
Rollback vs. redeployment
| Action | What it does | When to use it |
|---|---|---|
| Rollback | Creates a new deployment using the commit from a previous successful deployment and tracks the rollback in history. | When the latest deployment introduced a problem and you need to restore the previous working version. |
| Redeployment | Creates a new deployment on the configured branch using the latest commit. | When you have pushed a fix to your repository and want to deploy it. |
The typical recovery flow is: execute the rollback to restore service, diagnose the source failure, push a fix, and then redeploy through the normal flow.
Next steps
Deployment Diagnosis
Use AI-powered analysis to understand why the source deployment failed before your next attempt.
Deployment History
Browse and filter your deployment history to find the right rollback target.
Deployment Hooks
Ensure your hooks are compatible with both current and older code before rolling back.
Artifacts
Store, inspect, and download the build outputs that Devpilot produces during deployment — archives, binaries, packages, and anything else you want preserved alongside a release.
Deployment Diagnosis
Use Devpilot's AI-powered deployment diagnosis to analyze failed deployments, identify the root cause, and follow suggested fixes.