CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • How to restore foreign keys?
Pages: [1]

Author Topic: How to restore foreign keys?  (Read 1220 times)

ronald

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 5
How to restore foreign keys?
October 09, 2008, 11:13:03 pm
I am still running 2.1beta3 on Drupal 6.5, keeping Drupal and CiviCRM data in the same database.

I have religiously been backing up my database before any db updates, using the "Demonstration Site" module. Recently I had to roll back a change for the first time and tried to restore the database with the same tool, however I got wads of error messsages, all pertaining to CiviCRM (see here).

Discussing the problem in the "Demonstration Site" issue queue linked above revealed that the module does not support foreign keys. Now I am wondering if there is a way to restore the foreign keys without losing the data in the database. It would not be an absolute catastrophe if I lost the data at this time, but it would be relevant for me to know for the future if that is possible or not. (I.e. if I can keep using "Demonstration Site" and still restore my CiviCRM data if needed.)

Any advice would be greatly appreciated.

TIA,

Ronald
« Last Edit: October 10, 2008, 12:02:11 am by ronald »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: How to restore foreign keys?
October 10, 2008, 06:56:23 am

You might be able to restore the DB saved by Demonstration Site by

adding this line to the beginning of your sql dump file

/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;


and this line to the end of the file

/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;

In future, we would recommend you use a backup program that takes care of FK constraints. You might want to read:

http://dev.mysql.com/doc/refman/5.0/en/backup.html
http://www.google.com/search?q=mysql+backup+open+source&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a (zmanda is a popular option)

lobo


A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

ronald

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 5
Re: How to restore foreign keys?
October 10, 2008, 07:58:47 am
Thanks for the advice and the pointers, much appreciated.

Cheers,

Ronald

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • How to restore foreign keys?

This forum was archived on 2017-11-26.