You are here

function backup_migrate_exec in Backup and Migrate 8.3

Same name and namespace in other branches
  1. 8.2 backup_migrate.module \backup_migrate_exec()
  2. 6.3 backup_migrate.module \backup_migrate_exec()
  3. 7.3 backup_migrate.module \backup_migrate_exec()
  4. 7.2 backup_migrate.module \backup_migrate_exec()

Execute a command line command. Returns false if the function failed.

7 calls to backup_migrate_exec()
backup_migrate_destination_db_mysql::_backup_db_to_file_mysqldump in includes/destinations.db.mysql.inc
Backup the databases to a file using the mysqldump command.
backup_migrate_destination_filesource::_backup_to_file_cli in includes/sources.filesource.inc
Backup from this source.
backup_migrate_destination_filesource::_restore_from_file_cli in includes/sources.filesource.inc
Restore to this source.
backup_migrate_files_destination_archivesource::_backup_to_file_cli in includes/sources.archivesource.inc
Backup from this source.
backup_migrate_filter_compression::_backup_migrate_gzip_decode in includes/filters.compression.inc
Gzip decode a file.

... See full list

3 string references to 'backup_migrate_exec'
backup_migrate_destination_filesource::_backup_to_file_cli in includes/sources.filesource.inc
Backup from this source.
backup_migrate_destination_filesource::_restore_from_file_cli in includes/sources.filesource.inc
Restore to this source.
backup_migrate_files_destination_archivesource::_backup_to_file_cli in includes/sources.archivesource.inc
Backup from this source.

File

./backup_migrate.module, line 1820
Create (manually or scheduled) and restore backups of your Drupal MySQL database with an option to exclude table data (e.g. cache_*)

Code

function backup_migrate_exec($command, $args = array()) {
  if (!function_exists('exec') || ini_get('safe_mode')) {
    return FALSE;
  }

  // Escape the arguments
  foreach ($args as $key => $arg) {
    $args[$key] = escapeshellarg($arg);
  }
  $command = strtr($command, $args);
  $output = $result = NULL;

  // Run the command.
  $temp_name = drupal_tempnam('temporary://', 'mysql');
  exec($command . ' 2>' . realpath($temp_name), $output, $result);
  if ($result !== 0 && isset($args['%file'])) {
    file_put_contents($args['%file'], file_get_contents($temp_name), FILE_APPEND);
  }
  unlink($temp_name);
  return $result == 0;
}