fix tar -C parameter and create_backup_tar_data list

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2016-04-28 11:11:45 +02:00
parent ef7da53806
commit 9c9bbb81de

View File

@@ -61,7 +61,7 @@ function createCustomerBackup($data = null, $customerdocroot = null, &$cronlog)
} }
if ($has_dbs) { if ($has_dbs) {
$create_backup_tar_data .= makeCorrectDir($tmpdir . '/mysql'); $create_backup_tar_data .= makeCorrectDir($tmpdir . '/mysql')." ";
} }
unset($sql_root); unset($sql_root);
@@ -85,9 +85,9 @@ function createCustomerBackup($data = null, $customerdocroot = null, &$cronlog)
} }
if (! empty($tar_file_list)) { if (! empty($tar_file_list)) {
$cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'shell> tar -C '.escapeshellarg($tmpdir).' cfvz ' . escapeshellarg(makeCorrectFile($tmpdir . '/mail/' . $data['loginname'] . '-mail.tar.gz')) . ' ' . escapeshellarg(trim($tar_file_list))); $cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'shell> tar cfvz ' . escapeshellarg(makeCorrectFile($tmpdir . '/mail/' . $data['loginname'] . '-mail.tar.gz')) . ' ' . escapeshellarg(trim($tar_file_list)).' -C '.escapeshellarg($tmpdir));
safe_exec('tar -C '.escapeshellarg($tmpdir).' cfz ' . escapeshellarg(makeCorrectFile($tmpdir . '/mail/' . $data['loginname'] . '-mail.tar.gz')) . ' ' . escapeshellarg(trim($tar_file_list))); safe_exec('tar cfz ' . escapeshellarg(makeCorrectFile($tmpdir . '/mail/' . $data['loginname'] . '-mail.tar.gz')) . ' ' . escapeshellarg(trim($tar_file_list)).' -C '.escapeshellarg($tmpdir));
$create_backup_tar_data .= makeCorrectDir($tmpdir . '/mail'); $create_backup_tar_data .= makeCorrectDir($tmpdir . '/mail')." ";
} }
} }
@@ -96,9 +96,9 @@ function createCustomerBackup($data = null, $customerdocroot = null, &$cronlog)
$cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'Creating web-folder "'.makeCorrectDir($tmpdir . '/web').'"'); $cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'Creating web-folder "'.makeCorrectDir($tmpdir . '/web').'"');
safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir($tmpdir . '/web'))); safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir($tmpdir . '/web')));
$cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'shell> tar -C '.escapeshellarg($tmpdir).' cfz ' . escapeshellarg(makeCorrectFile($tmpdir . '/web/' . $data['loginname'] . '-web.tar.gz')) . ' --exclude ' . escapeshellarg($tmpdir) .' ' . escapeshellarg($customerdocroot)); $cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'shell> tar cfz ' . escapeshellarg(makeCorrectFile($tmpdir . '/web/' . $data['loginname'] . '-web.tar.gz')) . ' --exclude ' . escapeshellarg($tmpdir) .' ' . escapeshellarg($customerdocroot).' -C '.escapeshellarg($tmpdir));
safe_exec('tar -C '.escapeshellarg($tmpdir).' cfz ' . escapeshellarg(makeCorrectFile($tmpdir . '/web/' . $data['loginname'] . '-web.tar.gz')) . ' --exclude ' . escapeshellarg($tmpdir) .' ' . escapeshellarg($customerdocroot)); safe_exec('tar cfz ' . escapeshellarg(makeCorrectFile($tmpdir . '/web/' . $data['loginname'] . '-web.tar.gz')) . ' --exclude ' . escapeshellarg($tmpdir) .' ' . escapeshellarg($customerdocroot).' -C '.escapeshellarg($tmpdir));
$create_backup_tar_data .= makeCorrectDir($tmpdir . '/web'); $create_backup_tar_data .= makeCorrectDir($tmpdir . '/web')." ";
} }
if (!empty($create_backup_tar_data)) if (!empty($create_backup_tar_data))
@@ -106,8 +106,8 @@ function createCustomerBackup($data = null, $customerdocroot = null, &$cronlog)
$backup_file = makeCorrectFile($tmpdir . '/' . $data['loginname'] . '-backup_' . date('YmdHi', time()) . '.tar.gz'); $backup_file = makeCorrectFile($tmpdir . '/' . $data['loginname'] . '-backup_' . date('YmdHi', time()) . '.tar.gz');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Creating backup-file "'.$backup_file.'"'); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Creating backup-file "'.$backup_file.'"');
// pack all archives in tmp-dir to one // pack all archives in tmp-dir to one
$cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'shell> tar -C '.escapeshellarg($tmpdir).' cfz ' . escapeshellarg($backup_file) . ' ' . escapeshellarg($create_backup_tar_data)); $cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'shell> tar cfz ' . escapeshellarg($backup_file) . ' ' . escapeshellarg(trim($create_backup_tar_data)).' -C '.escapeshellarg($tmpdir));
safe_exec('tar -C '.escapeshellarg($tmpdir).' cfz ' . escapeshellarg($backup_file) . ' ' . escapeshellarg($create_backup_tar_data)); safe_exec('tar cfz ' . escapeshellarg($backup_file) . ' ' . escapeshellarg(trim($create_backup_tar_data)).' -C '.escapeshellarg($tmpdir));
// move to destination directory // move to destination directory
$cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'shell> mv ' . escapeshellarg($backup_file) . ' ' . escapeshellarg($data['destdir'])); $cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'shell> mv ' . escapeshellarg($backup_file) . ' ' . escapeshellarg($data['destdir']));
safe_exec('mv ' . escapeshellarg($backup_file) . ' ' . escapeshellarg($data['destdir'])); safe_exec('mv ' . escapeshellarg($backup_file) . ' ' . escapeshellarg($data['destdir']));