Aegir Quick Tip - Fixing Image links when Migrating a Site to a Different URL in Aegir

I'm always moving sites from a "dev" url to the production url using Aegir.  Something like dev.mysite.com will become mysite.com.

In doing this, drupal has image issues, but its easy to fix.  You just have to do a search and replace in your database for the urls of your multi-site install.

I usually do something like:

UPDATE node_revisions set body = replace (body, 'sites/dev.mysite.com/files', 'sites/mysite.com/files');
UPDATE files set filepath = replace (filepath, "sites/dev.mysite.com/files", "sites/mysite.com/files");
UPDATE variable set value= replace (value, 'sites/dev.mysite.com/files', 'sites/mysite.com/files');
UPDATE boxes set body = replace (body, 'sites/dev.mysite.com/files', 'sites/mysite.com/files');

I usually do this in phpmyadmin and it fixes everything up just fine.

Just remember to double check everything (backslashes, files not file, sites not sites, etc...) and make a database backup before you do this.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I assume these scripts are for Drupal6 only. Or am I missing something?

Doka

@Doka

Yes, there is an issue about it already: http://drupal.org/node/1196034

This is why we recommend this workflow on site import to Aegir: http://omega8.cc/import-your-sites-to-aegir-in-8-easy-steps-109

Best,
Grace

I have never had a problem whilst migrating sites within Aegir, but those queries are extremely useful on importing into Aegir from standalone sites that may or may not have been set up with multisite.

All those search/replace queries are already built-in in the Aegir for a long time and work on every site Rename task (Migrate), see: http://drupalcode.org/project/provision.git/blob/HEAD:/platform/drupal/d... and also this issue for D7 support: http://drupal.org/node/1196034

Oh nice, thanks for pointing that out. Looks like I need to update my aegir.

Sometimes, I have to update the teasers as well.
So the first update is:
UPDATE node_revisions set body = replace (body, 'sites/dev.mysite.com/files', 'sites/mysite.com/files'), teaser = replace (teaser, 'sites/dev.mysite.com/files', 'sites/mysite.com/files');

Post new comment