Answers.Body: <p>There is a known issue (<a href="https://www.drupal.org/project/backup_migrate/issues/2946311" rel="nofollow noreferrer">Too many connections in backup_migrate_source_db->_get_db_connection()</a>) 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.</p>
  
  <p>I would suggest two possible workarounds:</p>
  
  <ol>
  <li>Either uninstall Backup and Migrate and then reinstall an earlier version such as 3.2 or even 2.8.</li>
  <li><p>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:</p>
  
  <p><code>#!/bin/bash</p>
  
  <p># Database credentials
  user="username"
  password="db_password"
  host="localhost"
  db_name="db_name"</p>
  
  <p># Other options
  backup_path="/absolute_path_to_backup_folder"
  date=$(date +"%d-%b-%Y-%H-%M-%S")</p>
  
  <p># Set default file permissions
  umask 177</p>
  
  <p># Dump database into SQL file
  mysqldump --user=$user --password=$password --host=$host $db_name > $backup_path/$db_name-$date.sql</p>
  
  <p>#Compress the backup file
  #7z a $backup_path/$db_name-$date.7z $backup_path/*.sql
  gzip $backup_path/$db_name-$date.sql</p>
  
  <p>#Remove the original sql file
  #rm -I $backup_path/*.sql</p>
  
  <p># Delete files older than 30 days
  #find $backup_path/* -mtime +30 -exec rm {} \;
  find $backup_path/* -name *.sql.gz -mtime +30 -exec rm {} \;</code></p></li>
  </ol>
  
  <p>for which I have set up a Cron job to execute every day.</p>
  
  <p>Any debugging information you can provide for the issue will probably be welcome and help them in finding a fix.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-09T14:51:13.683Z
Answers.Text: 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 ?
Answers.UserDisplayName: Jacques-Marie Moranne
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-10T08:25:29.030Z
Answers.Text: 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.
Answers.UserDisplayName: Ben
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-10T08:33:55.293Z
Answers.Text: 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".
Answers.UserDisplayName: Ben
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-10T08:35:05.250Z
Answers.Text: 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 https://help.ubuntu.com/community/CronHowto.
Answers.UserDisplayName: Ben
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-10T11:13:53.690Z
Answers.Text: 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.
Answers.UserDisplayName: Jacques-Marie Moranne
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-09T09:15:42.503Z
Answers.LastActivityDate: 2019-01-09T09:15:42.503Z
Answers.UserDisplayName: Ben
Body: <p>Moving to Drupal 7.61 / Civi 7.8.2</p>
  
  <p>Using Backup &amp; Migrate, I realize that my Civi DB has never been saved (I can only do it manually via quick Backup) : </p>
  
  <p>Settings give the ability to back-up :</p>
  
  <ul>
  <li>Drupal DB </li>
  <li>Civi DB </li>
  <li>Public Files </li>
  <li>Entire site</li>
  </ul>
  
  <p>... based upon specific pertaining options (mostly exclusions).</p>
  
  <p>But only my Drupal DB is actually saved</p>
  
  <p>How can I have all of them saved, or select which should be ?</p>
  
Tags: <backups>
Title: How to Parameterize Backup & Migrate to have both DBs saved?
ThreadText: # How to Parameterize Backup & Migrate to have both DBs saved?
  
  (Asked by: username_0 on 2019-01-04)
  
  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 ?
  
  **Tags:** backups
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-01-09. Score: 3 | Accepted answer
  
  There is a known issue ([Too many connections in backup\_migrate\_source\_db->\_get\_db\_connection()](https://www.drupal.org/project/backup_migrate/issues/2946311)) 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.
  
  > **Comments:**
  > **username_0**: 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 ?  
  > **username_1**: 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.  
  > **username_1**: 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".  
  > **username_1**: 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 https://help.ubuntu.com/community/CronHowto.  
  > **username_0**: 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.  
  
  ---
  
  