Commit 06e49630 authored by anarcat's avatar anarcat Committed by anarcat

#691914 - port backup and restore to solaris backward tar implementation

parent dc08388c
......@@ -54,12 +54,17 @@ function drush_provision_drupal_provision_backup($url) {
$backup_file = drush_get_option('backup_file');
// Adds the site directory into the backup file
drush_log(dt("Adding sites directory to !backup_file", array('!backup_file' => $backup_file)), 'backup');
$olddir = getcwd();
// we need to do this because some retarded implementations of tar (e.g. SunOS) don't support -C
chdir(drush_get_option('sites_path') . "/$url");
if (substr($backup_file, -2) == 'gz') {
$command = "tar -C %s -p -c -z -f %s .";
// same as above: some do not support -z
$command = "tar cpf - . | gzip -c > %s";
} else {
$command = "tar -C %s -p -c -f %s .";
$command = "tar cpf %s .";
}
$result = provision_shell_exec($command, drush_get_option('sites_path') . "/$url", $backup_file);
$result = provision_shell_exec($command, $backup_file);
chdir($olddir);
if (!$result && !drush_get_option('force', false)) {
drush_set_error('PROVISION_BACKUP_FAILED', dt("Could not back up sites directory for drupal"));
......
......@@ -255,8 +255,14 @@ function provision_path_extract($path, &$target, &$reason) {
if (file_exists($path) && is_readable($path)) {
if (is_writeable(dirname($target)) && !file_exists($target) && !is_dir($target)) {
mkdir($target);
drush_log(sprintf("Running: tar -zpxf %s -C %s", $path, $target));
$result = provision_shell_exec("tar -zpxf %s -C %s", $path, $target);
$oldcwd = getcwd();
// we need to do this because some retarded implementations of tar (e.g. SunOS) don't support -C
chdir($target);
// same here: some do not support -z
$command = 'gunzip -c %s | tar pxf -';
drush_log(dt('Running: %comand in %target', array('%command' => sprintf($command, $path), '%target' => $target)));
$result = provision_shell_exec($command, $path);
chdir($oldcwd);
if ($result && is_writeable(dirname($target)) && is_readable(dirname($target)) && is_dir($target)) {
$target = TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment