diff --git a/db/Provision/Service/db/mysql.php b/db/Provision/Service/db/mysql.php index 28eafc2..4a20994 100644 --- a/db/Provision/Service/db/mysql.php +++ b/db/Provision/Service/db/mysql.php @@ -248,8 +248,19 @@ port=%s // Set the umask to 077 so that the dump itself is non-readable by the // webserver. umask(0077); + + // If a database uses Global Transaction IDs (GTIDs), information about this is written to the dump + // file by default. Trying to import such a dump during a clone or migrate will fail. So use the + // '--set-gtid-purged=OFF' option to suppress the restoration of GTIDs. GTIDs were added in MySQL version 5.6 + if (drush_get_option('provision_mysqldump_suppress_gtid_restore', FALSE)) { + $gtid_option = '--set-gtid-purged=OFF'; + } // if + else { + $gtid_option = ''; + } // else + // Mixed copy-paste of drush_shell_exec and provision_shell_exec. - $cmd = sprintf("mysqldump --defaults-file=/dev/fd/3 --single-transaction --quick --no-autocommit %s", escapeshellcmd(drush_get_option('db_name'))); + $cmd = sprintf("mysqldump --defaults-file=/dev/fd/3 %s --single-transaction --quick --no-autocommit %s", $gtid_option, escapeshellcmd(drush_get_option('db_name'))); // Fail if db file already exists. $dump_file = fopen(d()->site_path . '/database.sql', 'x'); diff --git a/provision.api.php b/provision.api.php index a0fafb4..a36fab5 100644 --- a/provision.api.php +++ b/provision.api.php @@ -27,6 +27,12 @@ * * provision_create_local_settings_file * Create a site 'local.settings.php' file if one isn't found, default TRUE. + * + * provision_mysqldump_suppress_gtid_restore + * Don't restore GTIDs from a database export. Set to TRUE for MySQL versions 5.6 and above to + * avoid having restores error out during operations such as cloning, migrating, and restoring from + * backup. Default is FALSE. + * */ /**