0

I am having a drupal site developed and ready on my local server which is a standard drupal Installation. Back on server I have a multisite setup with 3 sites all using same database with different prefix for each site. Now I want to move this site that is on local server to replace one of the site in the multi-site online.

I am confused with the following things:

  • How do I export the db from a single instant and import it on server? I only have phpmyadmin access. And all sites in multisite use same db and is prefixed.
  • How do I export the db from localhost with the required prefix.
  • Does the multisite db use all the tables I have in single instant?
  • Will importing the local tables to multi-site db overwrite the tables thats already there or will I have to delete the tables online first and then import?

What are the best steps to follow for my problem, I saw many conflicting info online and in this community. As I am doing this on a live site, dont wan't to break it.

3

On the local machine:

  1. Execute SHOW TABLES to get a list of tables.
  2. Copy the table names into a text file, one table per line.
  3. Use your favorite tool to transform the lines from

    tablename

    to

    RENAME TABLE tablename TO prefix_tablename;

    Choose a table prefix different from the ones you have on the server. This ensures that no tables are overwritten when you import them to the server.

  4. Execute the resulting script on the DB of your local installation.

  5. Edit the settings.php to use the chosen table prefix.
  6. Export the local database. You can use Backup and Migrate but you have to make sure to also export the structure of the cache tables, but not the content. You can also use phpMyAdmin, but you should empty (not delete) the cache tables and the watchdog table first. These tables can get quite large and their content is not essential to the operation of a drupal site.

On the server:

  1. Import the SQL file of the backup into phpMyAdmin. This creates the necessary tables and fills them with the contents from you local machine. If the file is large, you might run into issues with max_execution_time and upload_max_filesize.
  2. Create a new subdirectory under the sites directory and copy your local settings.php file into it.
  3. Copy any modules, themes and file uploads required by your local site to the server.
  4. Copy sites/example.sites.php to sites/sites.php. The file sites/sites.php allows you to map Drupal sites to arbitrary paths within the sites directory. Read the comments in that file for details.
  5. Edit sites/sites.php so that the URL of the site to replace points to your new directory within sites.

    Now you can make further adjustments to your new site without damaging the old one. Problems are usually caused by different locations of modules, themes and uploaded files. These problems cannot be solved by a simple search and replace on the database, because of the way Drupal stores some configuration information (serialized PHP arrays or objects). You might want to switch the site to maintenance mode while fixing such problems.

  6. In case of panic, remove sites/sites.php and you have your old site back.

  • I actually already have the particular site setup in the production server. So there are table which i have to overwrite and the site folder is also there. I am confused on how to overwrite. – esafwan Aug 28 '12 at 11:50
  • Why do you want to overwrite anything? Do you have content that should be migrated from the old site to the new one? – Oswald Aug 28 '12 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.