function backup_migrate_files_destination_archivesource::_backup_to_file_cli in Backup and Migrate 6.3
Same name and namespace in other branches
- 8.3 includes/sources.archivesource.inc \backup_migrate_files_destination_archivesource::_backup_to_file_cli()
- 7.3 includes/sources.archivesource.inc \backup_migrate_files_destination_archivesource::_backup_to_file_cli()
Backup from this source.
Overrides backup_migrate_destination_filesource::_backup_to_file_cli
File
- includes/
sources.archivesource.inc, line 97 - A destination type for saving locally to the server.
Class
- backup_migrate_files_destination_archivesource
- 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'];
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();
$manifest = $this
->generate_manifest();
$db = $this
->get_db();
rename($db, $temp . '/database.sql');
rename($manifest, $temp . '/MANIFEST.ini');
$file
->push_type('sitearchive');
$link = $temp . '/docroot';
$input = realpath($this
->get_location());
backup_migrate_exec("ln -s %input %link; tar --dereference -C %temp -rf %output {$exclude} .", array(
'%output' => $file
->filepath(),
'%input' => $input,
'%temp' => $temp,
'%link' => $link,
));
return $file;
}
return FALSE;
}