79

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?

Community
  • 1
  • 1
readonly
  • 343,444
  • 107
  • 203
  • 205

4 Answers4

156

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

cap deploy:rollback

readonly
  • 343,444
  • 107
  • 203
  • 205
  • Good resource. This one appears to have a couple more methods and more documentation: http://capitate.rubyforge.org/recipes/deploy.html – JellicleCat Oct 11 '11 at 18:46
  • What if I want to rollback not just to the previous deploy, but to some earlier one? Is there some argument or environment variable to pass to this command specifying which version I want to rollback to? – Ernesto Apr 08 '15 at 12:49
  • Is there any way to rollback to some specific version? [This answer](http://stackoverflow.com/a/30484093/2945616) is not working in Capistrano 3. – Radix Oct 21 '15 at 07:21
52

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.

Snowcrash
  • 80,579
  • 89
  • 266
  • 376
15

simple roll back:

$ cap deploy:rollback

rollback to specific version:

$ cap deploy:rollback -s previous_release= [path to previous release under releases folder ]
Малъ Скрылевъ
  • 16,187
  • 5
  • 56
  • 69
Rhythm Shahriar
  • 311
  • 2
  • 6
9

Actually it is

cap deploy:rollback:code

deploy:rollback may rollback to a previous revision, not necessarily a previously deployed revision.

Martin
  • 15,820
  • 4
  • 47
  • 56
  • 6
    I realize significant time separates this answer from the accepted answer, but according to the code for the `rollback` namespace, as of today, the default action for `cap deploy:rollback` does the same thing as a code rollback **plus** a restart. Ref: https://github.com/capistrano/capistrano/blob/master/lib/capistrano/recipes/deploy.rb#L325 – jefflunt Sep 07 '12 at 03:58