4

Moving to Drupal 7.61 / Civi 7.8.2

Using Backup & Migrate, I realize that my Civi DB has never been saved (I can only do it manually via quick Backup) :

Settings give the ability to back-up :

  • Drupal DB
  • Civi DB
  • Public Files
  • Entire site

... based upon specific pertaining options (mostly exclusions).

But only my Drupal DB is actually saved

How can I have all of them saved, or select which should be ?

1 Answer 1

3

There is a known issue (Too many connections in backup_migrate_source_db->_get_db_connection()) with recent versions of Backup and Migrate from 3.3 onwards which prevents CiviCRM from backing up as well is Drupal. If you use version 3.3 or later it is likely that you will not be able to backup the CiviCRM database as well as the Drupal database. However, you should still be able to backup the Drupal database.

I would suggest two possible workarounds:

  1. Either uninstall Backup and Migrate and then reinstall an earlier version such as 3.2 or even 2.8.
  2. Leave the latest version of Backup and Migrate in place and use it to backup the Drupal database only and set up a bash script that gets triggered by Cron to back up the CiviCRM database. This is what I am doing. The script I am using is:

    #!/bin/bash

    # Database credentials user="username" password="db_password" host="localhost" db_name="db_name"

    # Other options backup_path="/absolute_path_to_backup_folder" date=$(date +"%d-%b-%Y-%H-%M-%S")

    # Set default file permissions umask 177

    # Dump database into SQL file mysqldump --user=$user --password=$password --host=$host $db_name > $backup_path/$db_name-$date.sql

    #Compress the backup file #7z a $backup_path/$db_name-$date.7z $backup_path/*.sql gzip $backup_path/$db_name-$date.sql

    #Remove the original sql file #rm -I $backup_path/*.sql

    # Delete files older than 30 days #find $backup_path/* -mtime +30 -exec rm {} \; find $backup_path/* -name *.sql.gz -mtime +30 -exec rm {} \;

for which I have set up a Cron job to execute every day.

Any debugging information you can provide for the issue will probably be welcome and help them in finding a fix.

6
  • Thank you Ben. I tried to install 2.8 version, but it does not seem to give the ability to backup other DB than the "default" Drupal DB. So, I am interested in your script, but not being a programmer, I have questions : where do you put this script ? Is it a stand alone file or must it be added inside an other file ? How do you call it ? Jan 9, 2019 at 14:51
  • Hi Jack-Marie, you can use version 2.8 to backup CiviCRM as well as the Drupal database. If you go to the backup and migrate settings, and then go to Destinations, you can add a MySQL database there, which you can then use as a source for backing up.
    – Ben
    Jan 10, 2019 at 8:25
  • The code I gave you goes in a stand-alone file, it is not part of another file. You need to give it the file ending ".sh". so for instance you could call it "backup_script.sh". How you then execute the script depends a little bit on how your hosting is configured. If you are given access to your Cron tab then you would need to go in and add a line in the Cron tab to execute the script. To run the script once a day at midnight you would add the line "00 00 * * * path/to/your/script/backup_script.sh".
    – Ben
    Jan 10, 2019 at 8:33
  • Crontab is a function that allows you to schedule commands to run at certain times, and is usually present on most hosting. There is a tutorial on crontab at help.ubuntu.com/community/CronHowto.
    – Ben
    Jan 10, 2019 at 8:35
  • Thank you Ben for all this information ; but I realize that there is an automatic daily back-up on my hosting cPanel (kept 7 days) + a manual one that I can run once a day fairly easily. I think I will use it, but I keep in mind your both suggestions (and I check your answer. Jan 10, 2019 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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