You are here

function backup_migrate_destination_filesource::_backup_to_file_cli in Backup and Migrate 6.3

Same name and namespace in other branches
  1. 8.3 includes/sources.filesource.inc \backup_migrate_destination_filesource::_backup_to_file_cli()
  2. 7.3 includes/sources.filesource.inc \backup_migrate_destination_filesource::_backup_to_file_cli()

Backup from this source.

1 call to backup_migrate_destination_filesource::_backup_to_file_cli()
backup_migrate_destination_filesource::backup_to_file in includes/sources.filesource.inc
Backup from this source.
1 method overrides backup_migrate_destination_filesource::_backup_to_file_cli()
backup_migrate_files_destination_archivesource::_backup_to_file_cli in includes/sources.archivesource.inc
Backup from this source.

File

includes/sources.filesource.inc, line 121
A destination type for saving locally to the server.

Class

backup_migrate_destination_filesource
A destination type for saving locally to the server.

Code

function _backup_to_file_cli($file, $settings) {
  if (!empty($settings->filters['use_cli']) && function_exists('backup_migrate_exec') && function_exists('escapeshellarg')) {
    $excluded_paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
    $exclude = array();
    foreach ($this
      ->get_excluded_paths($excluded_paths) as $path) {
      $exclude[] = '--exclude=' . escapeshellarg($path);
    }
    $exclude = implode(' ', $exclude);

    // Create a symlink in a temp directory so we can rename the file in the archive.
    $temp = backup_migrate_temp_directory();
    $file
      ->push_type('tar');
    backup_migrate_exec("tar --dereference -C %input -rf %output {$exclude} .", array(
      '%output' => $file
        ->filepath(),
      '%input' => $this
        ->get_realpath(),
      '%temp' => $temp,
    ));
    return $file;
  }
  return FALSE;
}