Making database changes to Drupal multi-sites

by Matt Danger on December 21, 2009

The company I work for hosts over 150 Drupal sites in a multi-site configuration and every so often I need to publish a change to the code that requires a database change. The large number of sites we host means that performing manual changes would require too much time and carries a chance of error. I’ve come up with a simple solution.

I first create a PHP script that bootstraps Drupal. Here is an example of a script that will rebuild the menu router tables.

// Bootstrap
require_once('includes/bootstrap.inc');
require_once('includes/common.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 
// Rebuild menus
menu_rebuild();
print 'Menu rebuild complete\n';

I name this script rebuild_menus.php and upload it to my Drupal directory. Then, I create a text file on my desktop that contains a list of all the Drupal websites. This is an abbreviated example:

http://example1.com
http://example2.com
http://example3.com
http://example4.com

Finally, I execute the script on all the sites by running the following command:

for url in `cat list.txt`; do echo "Running script on $url"; curl $url/rebuild_menus.php; echo; done

:, , , ,
3 comments for this entry:
  1. LUKE


    Pillspot.org. Canadian Health&Care.No prescription online pharmacy.Best quality drugs.Special Internet Prices. High quality pills. Buy pills online

    Buy:Lipothin.Acomplia.Advair.Ventolin.Lasix.Seroquel.Wellbutrin SR.SleepWell.Female Cialis.Amoxicillin.Lipitor.Benicar.Aricept.Zetia.Buspar.Cozaar.Female Pink Viagra.Zocor.Nymphomax.Prozac….

  2. AARON


    MedicamentSpot.com. Canadian Health&Care.Best quality drugs.No prescription online pharmacy.Special Internet Prices. Low price drugs. Order drugs online

    Buy:Petcam (Metacam) Oral Suspension.100% Pure Okinawan Coral Calcium.Accutane.Actos.Valtrex.Human Growth Hormone.Zovirax.Nexium.Prednisolone.Arimidex.Prevacid.Synthroid.Zyban.Retin-A.Lumigan.Mega Hoodia….

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Send me a message on AIM!

Friends

Read what I read...