Posted by excaliburst on October 30, 2009 at 8:12am
Jump to:
| Project: | Backup and Migrate |
| Version: | 6.x-1.2 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Issue Summary
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
Comments
#1
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
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
you can always do a search replace on the backup file changing all instances of your old prefix to the new.
#4
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
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.sqlAnd a non-prefixed DB becomes prefixed. :-)
#6
Automatically closed -- issue fixed for 2 weeks with no activity.
#7
I'm trying to get this done manually.
The old database from a single site install doesn't use prefixes. The new database at a multisite install does use prefixes. In fact the database contains one other drupal installation.
In the mysql-file I changed all instances of
'old_table_name'to'new_prefix_old_table_name'.Moved the files, modules and theme directories to the appropriate new place at /sites/newsitename
When I try to run the restore no changes at all are made to the database.
Are any other adjustments needed?
edit: oh and btw this restore ran spotless on a local test server, but that was single-site to single-site though.
#8
Did you ever figure this out?
#9
Can't really remember. :(