4

I'm not asking if I can update my website with Drush. I'm not asking if Drush can make it in maintenance mode.

My question is ... if I'm using the command drush up to update my Drupal core or a module is the best practice to put my website on maintenance mode or does not matter?

In the past, I update all my modules without putting my website in maintenance mode, and so far I have not any problems, but I'm looking for the best practice.

BTW, I already test my Drupal core update in a Dev environment, and everything is working fine.

9

The first bit of advice here is to always run drush up on a dev or staging site first, before running it on a production site. Sometimes, due to bugs or incompatibilities, upgrades can break a previously-working site. It is therefore always best to test your upgrade before bringing it live. After testing, it is also best if you move the exact files that you tested from dev to live rather than run drush up again. You never know, someone might publish a new release while you are testing!

When you run drush up on your test site, you will notice at the end that Drush will report either "No database updates", or it will run an updatedb, and you will see a report on the database changes that you made.

If there are no database updates required, then generally speaking, it is safe to update your code without putting your site in maintenance mode. Note, however, that there is a small risk that a web request might be processed when only some of the files in your site have been upgraded. Since it only takes a small amount of time to git pull or rsync your files, this is only likely to be a problem if your site gets a lot of traffic. If you are concerned about this, you could put your site into maintenance mode, or better yet, put up an 'in progress' page by adjusting your web server's configuration.

If database updates are required, it is a good idea to put your site into maintenance mode before updating it. After copying the files to your production system, run drush updatedb to run the database updates. When database updates are required, it is common for them to do operations such as add new columns or tables to your database. The new code in core or your contrib modules may assume these schema changes have been made, and may crash if run prior to the completion of the database update. drush updatedb can take a little while to run, so it is more likely that you might serve a web request before it finishes.

Note that if there ever is a problem, it would only be observed by a small number of clients, and would be fixed with a simple page refresh in the browser. Since you are probably watching your updatedb run, you would probably never see these failures yourself. It is best to keep your site clean from transient failures, though, so maintenance mode is the safer option.

It is a good idea to script the update operation, so that it will run smoothly and easily every time. See drush_deploy and upgradepath for two example projects that do this.

| improve this answer | |
  • Its looks very similar of what Pantheon does for their workflow(That's what I used 90% of my projects). I appreciated the explanation by client is very happy with his new method of updating his website. – itsdarrylnorris Oct 17 '14 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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