How I manage Drupal Upgrades with Lots O' Symlinks

This is cut from a quick and dirty email that I wrote to someone. It may not be well organized or explained, but I thought it was better posted here than nowhere at all.

Ok so the trick that I use is to use the multiple site feature of drupal to make upgrades easier. I use several symbolic links on the file system to make it all work let me describe it here.

My hosting company allows me to host multiple domains on the same account. by default the addon domains document roots are sub folders of my main domain's document root. for example it's like this:

~/public_html
~/public_html/site1
~/public_html/site2
~/public_html/site3
~/public_html/site4

so if I put an index file in each of those 5 directories it would be the index file for the appropriate main domain, or one of the 4 addon domains.

I then untar drupal in the main web root so it's like this:

~/public_html
~/public_html/drupal-5.27
~/public_html/site1
~/public_html/site2
~/public_html/site3
~/public_html/site4

The way drupal works for multiple domains, you point the web root for each site to the drupal directory and then the php looks at the domain name and matches the appropriate folder in the sites directory

~/public_html
~/public_html/drupal-5.27/sites/site1.com
~/public_html/drupal-5.27/sites/site2.com
~/public_html/drupal-5.27/sites/site3.com
~/public_html/drupal-5.27/sites/site4.com

So what I do to make upgrades easy is that I move that sites directory out of the current copy of drupal and symlink it:

~/public_html
~/public_html/sites/site1.com
~/public_html/sites/site2.com
~/public_html/sites/site3.com
~/public_html/sites/site4.com
~/public_html/drupal-5.27/sites is a symlink to ~/public_html/sites

This gets all the customized data for each drupal site out of the version specific directory.

I then create these symlinks for each site to point it's document root to the drupal install

~/public_html/site1 symlink to ~/public_html/drupal-5.27
~/public_html/site2 symlink to ~/public_html/drupal-5.27
~/public_html/site3 symlink to ~/public_html/drupal-5.27
~/public_html/site4 symlink to ~/public_html/drupal-5.27

so the sub domains web root symlink to the drupal version and in the drupal version the sites dir symlinks to my permanant sites dir.

Now when upgrade time comes along I unpack the new drupal

~/public_html
~/public_html/drupal-5.27
~/public_html/drupal-5.28

I then delete the sites dir in the new drupal and link it to my permanent sites dir.

~/public_html/drupal-5.28/sites symlinks to ~/public_html/sites

Then I change the simlink for each subdomain to the new drupal.

~/public_html/site1 symlink to ~/public_html/drupal-5.28
~/public_html/site2 symlink to ~/public_html/drupal-5.27
~/public_html/site3 symlink to ~/public_html/drupal-5.27
~/public_html/site4 symlink to ~/public_html/drupal-5.27

so i just updated site1's symlink, I then go into the update.php for site one and have it update to the new drupal. I do that for each site and I'm done.

It sounds like a lot of steps. but it goes pretty smothly becuase I'm never copying real site data, just shuffling around symlinks.

Category: