Can Backup from single Drupal be restored into a Multisite Drupal?

excaliburst - October 30, 2009 - 08:12
Project:Backup and Migrate
Version:6.x-1.2
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Can this be done without compromising the Multisite DB structure?

I am using shared files structure on this Multisite.

If so - can I just copy the file into the Backup & Migrate folder structure and restore via the normal Backup & Migrate GUI?

If not - How should I go about this then?

Thanks

Morten

#1

ronan - October 31, 2009 - 19:16
Status:active» fixed

This should work, but it depends on your specific setup. You should try it out on a test version of your site and see what happens.

Backup and migrate will not convert table prefixes, so if you're using a db table prefix the destination site has to use the same prefix.

Let me know if this doesn't work of if you have any other questions.

#2

excaliburst - November 9, 2009 - 08:02

Hi Ronan,

The single Drupal site I would like to backup and restore in a multi was not initially prefixed, as this was not necessary on a single Drupal... So this will stop the migration...?

Thanks

Morten

#3

VeryMisunderstood - November 9, 2009 - 08:06

you can always do a search replace on the backup file changing all instances of your old prefix to the new.

#4

excaliburst - November 9, 2009 - 09:45

You mean the replace the prefixes in the sql backup file.

OK. Thanks thats good to know. Then I should be able to go this route if I ultimate decide to.

Thanks Misunderstood.

BR

Morten

#5

dman - November 9, 2009 - 09:59

Can be tricky, but not too hard.
A snippet from my drush extensions for site synchronizations may illustrate how I did it.

<?php
     
// IF $old_prefix is set, then we should convert from that prefix to this one!
      // TRANSCODE ON THE FLY!
      // Note isset(), not is_empty() because maybe we need to go from no-prefix to a-prefix;
     
if (isset($old_prefix) && $old_prefix != $new_prefix) {
       
// Scary regexp may be hazardous to your health
        // newlines just to prettify the display.
       
drush_print("{$WARNING}Caution{$_WARNING} {$ACTION}Transcoding database{$_ACTION} on the fly to rename tables with a old_prefix='$old_prefix' to prefix='$new_prefix' ");
       
$transcode = "\\\n | sed  -e 's/TABLE `{$old_prefix}\\([^`]*\\)`/TABLE `{$new_prefix}\\1`/g' ";
       
$transcode .= "\\\n | sed  -e 's/TABLES `{$old_prefix}\\([^`]*\\)`/TABLES `{$new_prefix}\\1`/g' ";
       
$transcode .= "\\\n | sed  -e 's/TABLE IF EXISTS `{$old_prefix}\\([^`]*\\)`/TABLE IF EXISTS `{$new_prefix}\\1`/g' ";
       
$transcode .= "\\\n | sed  -e 's/INSERT INTO `{$old_prefix}\\([^`]*\\)`/INSERT INTO `{$new_prefix}\\1`/g' ";
       
$transcode .= "\\\n";
      }

     
// Adding () to protect the pipe. STDERR redirect kills it otherwise.
     
$pass = empty($LOCAL_DB_PASSWORD) ? "" : "-p$LOCAL_DB_PASSWORD";
     
$command = "( cat $backupfilepath $transcode | mysql $local_mysql_args ) ";
?>

- for illustration only. Full working code in CVS, so I can go :

drush restore database --old-prefix='' --new-prefix='subsite1_' path/to/db_dump.sql

And a non-prefixed DB becomes prefixed. :-)

#6

System Message - November 23, 2009 - 10:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.