4

When running updates for core and modules in a multisite configuration where modules are shared (sites/all/modules), are database updates applied across the multiple site's databases or do you need to run updatedb for each?

6

You need to run updatedb on each site individually. Note that as soon as you update the shared code, any site that has not had updatedb run could show errors or otherwise fail to function. You should therefore take all of the sites offline prior to updating the code, and bring each site back online again after updatedb completes.

  • Standard procedure for us is to test the code update and make sure the site functions with the new code without update.php being ran. 99% of the time things work as they should. If they don't then I have a bash script that runs drush -y updatedb & for all sites so the update runs ASAP. – mikeytown2 Oct 28 '14 at 19:13
  • If drush reports that no database updates are necessary when you run updatedb in testing, then you do not need to take your site offline. Otherwise, you should, unless you don't mind a few seconds of intermittent errors every once in a great while. – greg_1_anderson Oct 28 '14 at 20:32
2

I haven't experienced anything quite as disruptive as that... but it is definitely possible. I bashed a quick script that runs updates on all sites defined in the .drush/aliases.drushrc.php file. This will ensure all sites are updated separately even if they have shared contributes (the code will be updated by the first but each will run the updatedb.

---
#!/bin/bash

. ~/.bash_profile

base='/usr/local/apache/htdocs/drupal7'
cd $base



#take all sites offline before updating core/common contributes
for site in `drush sa|grep -v none|grep -v self|grep -v default`; do
  drush use $site
  drush vset maintenance_mode 1
done

#update all sites defined in /root/.drush/aliases.drushrc.php
for site in `drush sa|grep -v none|grep -v self|grep -v default`; do
  echo "Updating $site"
  drush use $site
  drush upc -y
  chown -R apache.apache *
  drush updb -y
  #restore current site from maintenance mode.
  drush vset maintenance_mode 0
done

---

output follows so you can see it works for yourself.

# ./update.sh
Updating atlantra.com
Site set to atlantra.com
 Name                Installed Version  Proposed version  Message
 Display Suite (ds)  7.x-2.6            7.x-2.7           Update available
 Store (ubercart)    7.x-3.7            7.x-3.8           SECURITY UPDATE available


Update information last refreshed: Tue, 10/28/2014 - 12:43
Security and code updates will be made to the following projects: Display Suite [ds-7.x-2.7], Ubercart [ubercart-7.x-3.8]

Note: A backup of your project will be stored to backups directory if it is not managed by a supported version control system.
Note: If you have made any modifications to any file that belongs to one of these projects, you will have to migrate those modifications after updating.
Do you really want to continue with the update process? (y/n): y
Project ds was updated successfully. Installed version is now 7.x-2.7.
Backups were saved into the directory /root/drush-backups/atlantra/20141028164424/modules/ds.                           [ok]
Project ubercart was updated successfully. Installed version is now 7.x-3.8.
Backups were saved into the directory /root/drush-backups/atlantra/20141028164424/modules/ubercart.                     [ok]
'all' cache was cleared in atlantra.com                                                                                 [success]
You have pending database updates. Run `drush updatedb` or visit update.php in your browser.                            [warning]
 Ds  7202  Increase the label storage length to 128.
Do you wish to run all pending updates? (y/n): y
Performed update: ds_update_7202                                                                                        [ok]
'all' cache was cleared in atlantra.com                                                                                 [success]
Finished performing updates.                                                                                            [ok]
Updating lawmatter.net
Site set to lawmatter.net

Update information last refreshed: 8 August 2014 - 9:30am
No code updates available.                                                                                              [ok]
 Field_collection  7003  Update field_collection_field_schema columns for all tables.
 Field_collection  7004  Add index on {$field_collection_field}_revision_id column for all tables.
 Module_filter     7200  Rebuild the menu and theme registry.
 Module_filter     7201  Old update that use to remove the module_filter_dynamic_save_position variable.
 Services          7402  Update 7402 adds services_user table so that services can see users createdupdate by itself.
 Uuid              7103  Modify the labels of all example entities created by the now removed
                         uuid_default_entities_example.module to make it clear they're examples.  Also remove the administrator
                         role of any example user.
 Ds                7202  Increase the label storage length to 128.
Do you wish to run all pending updates? (y/n): y
Performed update: field_collection_update_7003                                                                          [ok]
Performed update: module_filter_update_7200                                                                             [ok]
Performed update: ds_update_7202                                                                                        [ok]
Performed update: uuid_update_7103                                                                                      [ok]
Performed update: module_filter_update_7201                                                                             [ok]
Performed update: field_collection_update_7004                                                                          [ok]
Performed update: services_update_7402                                                                                  [ok]
'all' cache was cleared in lawmatter.net                                                                                [success]
Finished performing updates.                                                                                            [ok]
Updating rexialo.com
Site set to rexialo.com

Update information last refreshed: Tue, 10/28/2014 - 9:47am
No code updates available.                                                                                              [ok]
 Ds  7202  Increase the label storage length to 128.
Do you wish to run all pending updates? (y/n): y
Performed update: ds_update_7202                                                                                        [ok]
'all' cache was cleared in rexialo.com                                                                                  [success]
Finished performing updates.                                                                                            [ok]
  • Don't forget to take your sites offline while this runs. You need to take all of the sites offline before you run upc on the first one. – greg_1_anderson Oct 28 '14 at 18:54
  • added before: drush vset maintenance_mode 1 added after: drush vset maintenance_mode 0 – Neal Garrett Oct 28 '14 at 20:20
  • You should run the vset maintenance_mode in its own loop, prior to running upc the first time. upc on the first site in a multisite set will update code for all sites, so sites 2 - N might break before they are brought offline. – greg_1_anderson Oct 28 '14 at 20:30
  • albeit, I'm putting each site in maint mode as the site is updated. I think your point it to take them all offline before. .. I'll add a bash function and update accordingly. That would be the absolute safest way to go. – Neal Garrett Oct 28 '14 at 20:32
  • Yes, that's correct now, although you may bring each site online immediately after updatedb runs, as it was in the original version. – greg_1_anderson Oct 28 '14 at 21:46

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.