Splitting off a multisite sub-site

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by kevcol on September 12, 2009 at 1:17am

Hi there,

Is there a simple way to split off a subsite from a multisite installation? I'd like to hand off hosting of a site I created for a friend, but I'm having some issues with peeling it off my D6 multisite.

I figured I could just dump the database, copy the files and hand it over, but there seems to be problems with paths. (Doesn't help that the live URL has to point to my multisite until the standalone is ready.)

I've found a few sorta similar issues on the boards, but haven't been able to find a definitive answer (or at least one I can get to work.)

Thanks,
Kevin

Categories:

Comments

two things...

Posted by btopro on September 12, 2009 at 1:51am

Either change the directory under sites if he's just changing the URL but that doesn't seem like what you want.. OR....

Copy the DB, set it up on the new box. Go through and do a table / field level SQL replacement UPDATE query to alter the paths (particularly in the files table) so that the path's are correct. Then copy the file structure, delete all the sites's folders that are from your current multi-site stack. Then change the pathing on his site's folder to the new one.

....not that that's not a pain in the butt but unfortunately there's no real good solution that I know of for moving stuff like that. Something to do in the future (not sure how you setup ur sites folders) but I also do the com.sitefolder (in my situation everything's psu.edu so I make all the sites folders edu.courses.name) way of creating paths. That way none of the files are ever tied to a domain incase the domain changes.

Hope this helps :p

MySQL replacement

Posted by kevcol on September 12, 2009 at 6:49pm

Thanks.

Right, OK, it's the MySQL part that's been tripping me up. Is there any good way to do a global search and replace to change "sites/foo.com" with "sites/default"?

Had tried this in phpMyAdmin and but nothing was changed:
SELECT REPLACE('sites/foo.com','foo.com','default')

Then I tried to just do a text search-and-replace on exported database (replace "sites/foo.com" with "sites/default") and now I see uploaded files but I'm getting bootstrap errors:

Notice: unserialize() [function.unserialize]: Error at offset 2 of 32 bytes in includes/bootstrap.inc on line 478
Notice: unserialize() [function.unserialize]: Error at offset 388 of 492 bytes in includes/bootstrap.inc on line 478
Notice: unserialize() [function.unserialize]: Error at offset 389 of 3263 bytes in includes/bootstrap.inc on line 478
Notice: unserialize() [function.unserialize]: Error at offset 389 of 493 bytes in includes/bootstrap.inc on line 478
Notice: unserialize() [function.unserialize]: Error at offset 2 of 27 bytes in includes/bootstrap.inc on line 478
Notice: unserialize() [function.unserialize]: Error at offset 2 of 59 bytes in includes/bootstrap.inc on line 478
Notice: unserialize() [function.unserialize]: Error at offset 2 of 65 bytes in includes/bootstrap.inc on line 478
Notice: unserialize() [function.unserialize]: Error at offset 79 of 138 bytes in includes/bootstrap.inc on line 478
Notice: unserialize() [function.unserialize]: Error at offset 89 of 1357 bytes in includes/bootstrap.inc on line 478

Warning: Cannot modify header information - headers already sent by (output started at includes/bootstrap.inc:478) in includes/bootstrap.inc on line 630
Warning: Cannot modify header information - headers already sent by (output started at includes/bootstrap.inc:478) in includes/bootstrap.inc on line 631
Warning: Cannot modify header information - headers already sent by (output started at includes/bootstrap.inc:478) in includes/bootstrap.inc on line 632
Warning: Cannot modify header information - headers already sent by (output started at includes/bootstrap.inc:478) in includes/bootstrap.inc on line 633

Any suggestions on how to better update the database?

Thanks!

I believe you need to do an

Posted by btopro on September 13, 2009 at 1:55am

I believe you need to do an update query instead of a SELECT query. Like UPDATE table SET field = replace(searchfor,replacewith,field) and it'll work. That's what I've done on my files table before at least

cool, thanks. will give that

Posted by kevcol on September 13, 2009 at 8:20pm

cool, thanks. will give that a spin.

Cheers,
Kevin

Here's the what I tried via

Posted by kevcol on September 15, 2009 at 2:43pm

Here's the what I tried via PHPMyAdmin:

UPDATE 'files' SET 'filepath' = replace( 'filepath', 'sites/foo.com', 'sites/default' )

But I get an error:

Documentation

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''files' SET 'filepath' = replace('filepath','sites/foo.com','sites/d' at line 1

Am I missing something?

Thanks!

You probably don't want

Posted by Garrett Albright on September 15, 2009 at 4:04pm

You probably don't want quotes around the table and column names. Try:

UPDATE files SET filepath = replace(filepath, 'sites/foo.com', 'sites/default');

This is some meaningless additional text in the hopes that it will stop this submission from triggering gdo's draconian spam filter.

Also, some imagecache issues

Posted by kevcol on September 12, 2009 at 7:26pm

I'm also seeing some imagecache issues -- I stuck the files folder under sites/default, and now all the imagecache images in that file don't seem to show up.

(BTW, after flushing cache, I see the bootstrap errors intermittently instead of constantly -- some progress, perhaps.)

And theme "Directory Does Not Exist" oddness

Posted by kevcol on September 12, 2009 at 7:32pm

Oh, another pesky bug -- theme settings don't seem to be saving. When I go to theme configure, there are two errors up top:

  • The directory does not exist.
  • warning: array_merge() [function.array-merge]: Argument #2 is not an array in /includes/theme.inc on line 930.

I suppose a cleaner DB update might help avoid these issues.

You may be able to get away

Posted by Garrett Albright on September 14, 2009 at 5:23pm

You may be able to get away with this without doing any database hackery if you simply replicate the directory structure of the site as it was on the multisite server. For example, on the multisite server, you probably had some modules in sites/all/modules and some modules in sites/example.com/modules. Recreate those directories on the new server and make sure that every module which was under the former path on the old server is under that path on the new one, and likewise with the latter path. Likewise with sites/(all|example.com)/themes and sites/(all|example.com)/files. Does that make sense? I've successfully done it using this approach before, but YMMV.

If this doesn't work, another thing you should try before resorting to hacking the database is to disable all non-core modules and themes on the old site before doing a database dump. (Don't uninstall them, as that will cause lost data; just disable them.) Then, after you migrate, re-enable the needed modules.

Got it, thanks!

Posted by kevcol on September 21, 2009 at 5:43am

I got this, finally. I think the problem was the way I was outputting my database -- I was using the Backup & Migrate module on my Rackspace Cloud server and then using phpMyAdmin to import the database into my local MAMP database. I think I was picking up some schema info that was confusing the issue -- when I used phpMyAdmin to copy the database, I noticed I had fewer records, and the simple method Garret recommended above worked like a charm. (I'd guess the database hackery might work on the new output too, but that's a test for another day.)

Thanks!

Not sure if this helps, but...

Posted by chadhester on November 4, 2009 at 8:30pm

Hi all... I read through this post and found some issues with my site after splitting a single drupal install into a multisite install... basically, some of the themes were removed after the split. What I did was this, to figure out some items that were erroneous in the {variable} table:

First, temporarily modified bootstrap.inc after line 478.

<?php
//LINE 478:
$variables[$variable->name] = unserialize($variable->value);
//ADDED:
echo "Parsed: ".strval($variable->name)."<br />\n";
?>

I found errors like:
Notice: unserialize() [function.unserialize]: Error at offset 113 of 862 bytes in /var/www/www.example.com/public_html/includes/bootstrap.inc on line 479
Parsed: theme_zen_settings

I then located the offending variable and deleted the row in phpMyAdmin:

SELECT *
FROM variable
WHERE name LIKE "theme_%_settings"

Thank you all for your ideas... Your sharing makes things easier! :)

alternative approach

Posted by benlotter on November 22, 2010 at 2:14am

My approach is to do an export of the SQL tables to a .sql files with the table creates and inserts. This is done through PHPmyAdmin. Then I do a one-time mass search and replace for 'site2move.mysite.com' and change it to 'site2move.com'. I use NotePad++ to accomplish this. Then I do an import of the sql tables and inserts into the new database. The final thing I have to is run update.php on the new site and save settings on my theme.

Benjamin Lotter
"Delight thyself also in the LORD and He shall give thee the desires of thine heart." ~Psalm 37:4

Multisite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /