Posted on Wed, 05/04/2016 - 12:13
CiviCRM Drupal Backup and Migrate

CiviCRM Drupal is a winning combination, but they can be very fussy and demanding about how they are set up. Foreign key checks on database tables make it difficult to manage backups and site migrations for a CiviCRM data site in the way you would normally handle a Drupal website - but it can be done.

This recipe works for setting up a new development version - or copying data to a new server. CiviCRM is very fragile and needy when it comes to database tables and connections, so you need to get this exactly right. This recipe works for our environment - I can't guarantee it will work for yours!

CiviCRM.org documentation can end up being quite messy, this is an update to this article - https://forum.civicrm.org/index.php?topic=15052.0 which was an update to the information published here - http://wiki.civicrm.org/confluence/display/CRMDOC32/Moving+an+Existing+I...

1. Patch Backup & Migrate module
Backup and migrate can handle CiviCRM databases but it needs this patch to resolve foreign key problems.
https://www.drupal.org/node/1542274 - backup_migrate-comment-detection-1542274-44.patch

2. Copy your codebase (Drupal, CiviCRM modules, files, etc)... all of it. Fix settings.php and civicrm.settings.php to point at new paths and databases

3. Copy your databases
do an export for both dbs, your Drupal database and your CiviCRM database from backup and migrate excluding the data from these tables - but not the tables themselves

civicrm_acl_cache
civicrm_acl_contact_cache
civicrm_cache
civicrm_group_contact_cache

the original schema also excluded the civi domain table, but that is not excluded in this plan.

3.1 Install drupal
- on some installs we have had to run update.php to get past a weird error
- activate backup and migrate
- set private file system
- change default backup settings settings to use zip compression

4. Load your databases into the new server
restore drupal site from b&m files
restore civi db from b&m files

** make sure the data import is finished before you do anything - this can take a long time. Check in phpmyadmin that all tables are there.

5 check general site permissions
- check permissions on files/civicrm/templates_c/ folder

5.1 Delete cache files at /sites/default/files/civicrm/templates_c/*

5.2 delete the SECURE PAGES module - or disable it by adding this to settings.php
$conf['securepages_enable'] = 0;

6. Log into Drupal /user/login

disable all civi modules other than civi - or enable the civi module if all civi modules were previously disabled. Either way we want just the civi module enabled.

7. go to http:///admin/build/modules and enable CiviCRM (but not the other CiviCRM dependent modules)

8. cleanup caches / reset paths - go to /index.php?q=civicrm/admin/setting/updateConfigBackend&reset=1
review the settings there, adjust and click Save

8.1 fix extensions directory
civicrm/admin/setting/url?reset=1

9. Rebuild menus - go to /index.php?q=civicrm/menu/rebuild&reset=1
to rebuild the menus

10. Reset Paths
go to /index.php?q=civicrm/admin/setting/path?reset=1
review your settings, adjust and click Save

11. Re-enable other civi modules
go to /admin/build/modules and enable any other CiviCRM dependent modules that were disabled in step #1.

That should work and you should now have a duplicate of your Drupal CiviCRM installation set up on your new server! If you are experiencing odd behavior try clearing caches again.

Add new comment

Request a Free Quotation

Your Name