Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you roll back to the previously deployed version with capistrano?

Tags:

capistrano

I tried using "cap rollback" but I get the following error:

$ cap rollback

the task `rollback' does not exist

Is there some additional setup that I need to do to get rollbacks to work?

like image 323
readonly Avatar asked Jan 30 '09 19:01

readonly


People also ask

How does Capistrano deployment work?

When a deployment is run, Capistrano executes one task at a time on all servers and waits for that task to be done before moving on to the next one. If a task fails on a server, Capistrano exits without waiting for further tasks.

How does Capistrano handle rollbacks?

Capistrano provides basic rollback support, but as each application and system handles rollbacks differently, it is up to the individual to test and validate that rollback behaves correctly for their use case. For example, capistrano-rails will run special tasks on rollback to fix the assets, but does nothing special with database migrations.

Is it possible to roll back Kubernetes deployment?

However, even if you use techniques such as Rolling updates, there's still risk that your application doesn't work the way you expect it at the end of the deployment. Kubernetes and kubectl offer a simple mechanism to roll back changes to resources such as Deployments, StatefulSets and DaemonSets.

What happens when a Capistrano task fails?

If a task fails on a server, Capistrano exits without waiting for further tasks. In a multiple server situation, when a task fails on one server by exiting with a non-0 exit code, Capistrano closes the SSH connections to any still in-progress servers and their tasks exit.


3 Answers

Just found the answer here http://github.com/leehambley/railsless-deploy:

cap deploy:rollback

like image 106
readonly Avatar answered Oct 19 '22 06:10

readonly


If you're using different environments (e.g. staging, production) using the multistage gem (e.g. you have require 'capistrano/ext/multistage' in your deploy.rb file) then Capistrano defaults to staging. So, to roll back a production environment you would do:

cap production deploy:rollback

and, assuming you've got the defaults set, this would roll back staging:

cap deploy:rollback

Worth knowing if you're using different environments and wondering why it's not working for production.

like image 51
Snowcrash Avatar answered Oct 19 '22 06:10

Snowcrash


simple roll back:

$ cap deploy:rollback

rollback to specific version:

$ cap deploy:rollback -s previous_release= [path to previous release under releases folder ]
like image 15
Rhythm Shahriar Avatar answered Oct 19 '22 04:10

Rhythm Shahriar