public function GdprSqlMysql::dump in General Data Protection Regulation 8
Same name and namespace in other branches
- 8.2 modules/gdpr_dump/src/Sql/GdprSqlMysql.php \Drupal\gdpr_dump\Sql\GdprSqlMysql::dump()
- 3.0.x modules/gdpr_dump/src/Sql/GdprSqlMysql.php \Drupal\gdpr_dump\Sql\GdprSqlMysql::dump()
Execute a SQL dump and return the path to the resulting dump file.
Parameters
string|bool $file: The path where the dump file should be stored. If TRUE, generate a path based on usual backup directory and current date.
Return value
mixed Bool or nothing.
File
- modules/
gdpr_dump/ src/ Sql/ GdprSqlMysql.php, line 58
Class
- GdprSqlMysql
- Class GdprSqlMysql.
Namespace
Drupal\gdpr_dump\SqlCode
public function dump($file = '') {
$file_suffix = '';
$table_selection = $this
->get_expanded_table_selection();
$file = $this
->dumpFile($file);
// @todo: Cross-platform check.
$cmd = '{ ';
$cmd .= $this
->dumpCmd($table_selection);
// Append the RENAME commands at the end.
$cmd .= ' ; ' . $this
->createRenameCommands($table_selection) . '}';
// Gzip the output from dump command(s) if requested.
if (drush_get_option('gzip')) {
$cmd .= ' | gzip -f';
$file_suffix .= '.gz';
}
if ($file) {
$file .= $file_suffix;
$cmd .= ' > ' . drush_escapeshellarg($file);
}
// Avoid the php memory of the $output array in drush_shell_exec().
if (drush_op_system($cmd)) {
return drush_set_error('DRUSH_SQL_DUMP_FAIL', 'Database dump failed');
}
if ($file) {
drush_log(dt('Database dump saved to !path', [
'!path' => $file,
]), LogLevel::SUCCESS);
drush_backend_set_result($file);
}
}