From 06e496306469ee5f3057b52c90d26ff83a539121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Thu, 21 Jan 2010 18:13:08 -0500 Subject: [PATCH] #691914 - port backup and restore to solaris backward tar implementation --- platform/backup.provision.inc | 11 ++++++++--- provision.path.inc | 10 ++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/platform/backup.provision.inc b/platform/backup.provision.inc index f482840a..df75f766 100644 --- a/platform/backup.provision.inc +++ b/platform/backup.provision.inc @@ -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")); diff --git a/provision.path.inc b/provision.path.inc index 28323256..12a08de1 100644 --- a/provision.path.inc +++ b/provision.path.inc @@ -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; -- GitLab