2

More and more server-side file deployments are handled using git. It's nice and there are plenty of guides available how to setup your deployment workflow with git, rsync and others.

However, I'd like to ask what's the cleanest way to set deployment rollbacks, so that

  • Every time you deploy, you record the latest state before the deployment (no need to manually read through logs to find the commit)

  • What git commands use to rollback to the prior (recorded) state in the case deployment has unforeseen consequences

The scope of the question is Linux servers, shell scripting and command line git.

1
  • 1
    Somewhat off-topic, but I use capistrano for deployment, which covers those scenarios :) Jun 9, 2013 at 8:46

2 Answers 2

3

Note that there is no general solution to this problem. I would propose two solutions.

First one requires usage of Fabric and some deep thinking how to handle whole deployment process. For a Django site I maintain, I wrote a fabric script that deploys staging on every git commmit. Deploying from staging to production is then a simple fabric command that copies all the files to a new folder (increments a version by 1), for example from production/v55/ to production/v56/ (ok, it also does backups and runs migrations). If anything goes wrong, rollback command restores backups, and starts production environment from folder production/v55. Less talk, more code: https://github.com/kiberpipa/Intranet/blob/master/fabfile.py

The second option requires more reading and has a bigger learning curve, but also provides cleaner solution. As Lenin suggested to use framework with declarative configuration, I would propose to go a step further and learn a Linux distribution with declarative configuration - http://nixos.org/. NixOS has built in capabilities for distributed software deployment (including rollbacks) and also tools to deploy stuff from your machine https://github.com/NixOS/nixops. See also thesis on Distributed Software Deployment, which covers also your questions (being part of a much bigger problem): http://www.st.ewi.tudelft.nl/~sander/index.php/phdthesis

0

Please have a look at Capistrano and Chef which require ruby/ror support. But are great deployment tools. Python's fabric is also an awesome tool.

4
  • The tag wiki's are there to explain how to use the tag in the context of Stack Overflow and to give a bit of background information so people can identify which tag to use, please stop removing this information as you have on this suggested edit: stackoverflow.com/review/suggested-edits/2289558
    – Ben
    Jun 10, 2013 at 21:33
  • @Ben Firstly, you are not in context here. (Is there no other alternative way to communicate about it to be in context?) Secondly, I have edited it correctly. Its not a function of PHP. Rather a definition or declaration of the function. People wont use that function with int preg_match_all(). Rather they'd use preg_match_all() directly.
    – Lenin
    Jun 11, 2013 at 5:19
  • 1
    No, sorry there's no other way to communicate :-). Neither of us have enough reputation to edit it directly. I understand that it might not directly be a PHP function (though it is in the manual) and that the int is incorrect (you didn't remove this) but you still have to make the tag understandable. It's not about how to use the code but about how to use the tag. PHP is notorious for how bad people tag their questions and we don't want it slipping.
    – Ben
    Jun 11, 2013 at 7:59
  • I agree with you on the part that i didn't remove the int. But I edited it mentioning that its not the function how its to be used(by saying that its the definition how its present in the PHP library). I hope you get my point. And of course we should try to improve the understandability of these tags by making them easier to read. :thumbsup:
    – Lenin
    Jun 11, 2013 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.