Commit 3649983c authored by helmo's avatar helmo Committed by helmo

Issue #2774487 by helmo: Enable using bz2 for backup files

parent c504e074
......@@ -300,6 +300,9 @@ class Provision_FileSystem extends Provision_ChainedState {
// same here: some do not support -z
$command = 'gunzip -c %s | tar pxf -';
}
elseif (substr($path, -2) == 'bz2') {
$command = 'bunzip -c %s | tar pxf -';
}
else {
$command = 'tar -pxf %s';
}
......
......@@ -36,19 +36,28 @@ function drush_provision_drupal_provision_backup_validate($backup_file = NULL) {
}
if (!$backup_file) {
$suggested = d()->platform->server->backup_path . '/' . d()->uri . '-' . date("Ymd.His", time()) . '.tar.gz';
// Use format of mysite.com-2008-01-02, if already existing, add number.
$count = 0;
while (is_file($suggested)) {
$count++;
$suggested = d()->platform->server->backup_path . '/' . d()->uri . '-' . date('Ymd.His', time()) . '_' . $count . '.tar.gz';
}
$suggested = drush_provision_drupal_provision_backup_suggest_filename();
drush_set_option('backup_file', $suggested);
}
}
/**
* Util function to suggest a filename for a new site backup.
*/
function drush_provision_drupal_provision_backup_suggest_filename() {
$suffix = drush_get_option('provision_backup_suffix', '.tar.gz');
$suggested = d()->platform->server->backup_path . '/' . d()->uri . '-' . date("Ymd.His", time()) . $suffix;
// Use format of mysite.com-2008-01-02, if already existing, add number.
$count = 0;
while (is_file($suggested)) {
$count++;
$suggested = d()->platform->server->backup_path . '/' . d()->uri . '-' . date('Ymd.His', time()) . '_' . $count . $suffix;
}
return $suggested;
}
/**
* Implentation of hook_provision_backup()
*/
......@@ -84,6 +93,9 @@ function drush_provision_drupal_provision_backup() {
}
if (substr($backup_file, -2) == 'gz') {
$command = 'tar cpfz %s .';
}
elseif (substr($backup_file, -3) == 'bz2') {
$command = 'tar cpfj %s .';
} else {
$command = 'tar cpf %s .';
}
......
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