Backup download error
Summary
When trying to "download the backup" the procedure fails to copy the backup from /var/backup/site.tar.gz to /var/www/site.com/backup/site.tar.gz as the backup directory does not exist and is not created
Steps to reproduce
- create a manual backup of any web area using the "Make backup of web files" button
- once the backup has been created, click on the "download backup" button
- the log will show the error ERROR - Failed download of /var/www/clients/clientx/webxxx/backup/manual-webxxx_xxxx-xx-xx_xx.tar.gz
Correct behaviour
the backup should be copied to the /var/www/site.com/backup/ folder
Environment
Server OS + version: Ubuntu 20.04 ISPConfig version: 3.2.8p1
Proposed fix
Edit the downloadBackup function in the /usr/local/ispconfig/server/lib/classes/backup.inc.php file (starting line 631) like this
//* Copy the backup file to the backup folder of the website
if (!is_dir($domain['document_root'].'/backup/')) {
$app->system->set_immutable($domain['document_root'], false, false);
$app->system->mkdirpath($domain['document_root'].'/backup/', 0755, $domain['system_user'], $domain['system_group']);
$app->system->set_immutable($domain['document_root'], true, false);
}
elseif(file_exists($backup_dir.'/'.$filename) && is_dir($domain['document_root'].'/backup/') && !stristr($backup_dir.'/'.$filename, '..') && !stristr($backup_dir.'/'.$filename, 'etc')) {
$success = copy($backup_dir.'/'.$filename, $domain['document_root'].'/backup/'.$filename);
}
if (file_exists($domain['document_root'].'/backup/'.$filename)) {
chgrp($domain['document_root'].'/backup/'.$filename, $domain['system_group']);
chown($domain['document_root'].'/backup/'.$filename, $domain['system_user']);
chmod($domain['document_root'].'/backup/'.$filename,0600);
$app->log('Ready '.$domain['document_root'].'/backup/'.$filename, LOGLEVEL_DEBUG);
return true;
} else {
$app->log('Failed download of '.$domain['document_root'].'/backup/'.$filename , LOGLEVEL_ERROR);
return false;
}
I attach the modified file backup.inc.php
Edited by Lorenzo Valori