mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-05 15:37:03 +03:00
Backup plugin use tar stream
This commit is contained in:
parent
d1bab197c1
commit
f1c6ff3f2a
2 changed files with 26 additions and 21 deletions
|
|
@ -30,31 +30,36 @@ class BackupPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
return $this->jsonResponse(__FUNCTION__, false);
|
return $this->jsonResponse(__FUNCTION__, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sZipHash = \MailSo\Base\Utils::Sha1Rand();
|
|
||||||
$sZipFileName = APP_PRIVATE_DATA . $sZipHash . '.zip';
|
|
||||||
|
|
||||||
\file_put_contents(APP_PRIVATE_DATA.'cache/CACHEDIR.TAG', 'Signature: 8a477f597d28d172789f06886806bc55');
|
\file_put_contents(APP_PRIVATE_DATA.'cache/CACHEDIR.TAG', 'Signature: 8a477f597d28d172789f06886806bc55');
|
||||||
|
|
||||||
if (\class_exists('ZipArchive')) {
|
$sFileName = APP_PRIVATE_DATA . \MailSo\Base\Utils::Sha1Rand();
|
||||||
// $oZip = new \ZipArchive();
|
|
||||||
// $oZip->open($sZipFileName, \ZIPARCHIVE::CREATE | \ZIPARCHIVE::OVERWRITE);
|
if (false) {
|
||||||
// $oZip->setArchiveComment('SnappyMail/'.APP_VERSION);
|
$sFileName .= '.zip';
|
||||||
|
if (\class_exists('ZipArchive')) {
|
||||||
|
// $oArchive = new \ZipArchive();
|
||||||
|
// $oArchive->open($sFileName, \ZIPARCHIVE::CREATE | \ZIPARCHIVE::OVERWRITE);
|
||||||
|
// $oArchive->setArchiveComment('SnappyMail/'.APP_VERSION);
|
||||||
|
}
|
||||||
|
$oArchive = new \SnappyMail\Stream\ZIP($sFileName);
|
||||||
|
} else {
|
||||||
|
$sFileName .= '.tgz';
|
||||||
|
$oArchive = new \SnappyMail\Stream\TAR($sFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
$oZip = new \SnappyMail\Stream\ZIP($sZipFileName);
|
// $oArchive->addRecursive(APP_PRIVATE_DATA, '#/(cache.*)#');
|
||||||
// $oZip->addRecursive(APP_PRIVATE_DATA, '#/(cache.*)#');
|
$oArchive->addRecursive(APP_PRIVATE_DATA.'configs', 'configs');
|
||||||
$oZip->addRecursive(APP_PRIVATE_DATA.'configs', 'configs');
|
$oArchive->addRecursive(APP_PRIVATE_DATA.'domains', 'domains');
|
||||||
$oZip->addRecursive(APP_PRIVATE_DATA.'domains', 'domains');
|
$oArchive->addRecursive(APP_PRIVATE_DATA.'plugins', 'plugins');
|
||||||
$oZip->addRecursive(APP_PRIVATE_DATA.'plugins', 'plugins');
|
$oArchive->addRecursive(APP_PRIVATE_DATA.'storage', 'storage');
|
||||||
$oZip->addRecursive(APP_PRIVATE_DATA.'storage', 'storage');
|
|
||||||
if (\is_readable(APP_PRIVATE_DATA.'AddressBook.sqlite')) {
|
if (\is_readable(APP_PRIVATE_DATA.'AddressBook.sqlite')) {
|
||||||
$oZip->addFile(APP_PRIVATE_DATA.'AddressBook.sqlite');
|
$oArchive->addFile(APP_PRIVATE_DATA.'AddressBook.sqlite');
|
||||||
}
|
}
|
||||||
// $oZip->addFile(APP_DATA_FOLDER_PATH.'SALT.php');
|
// $oArchive->addFile(APP_DATA_FOLDER_PATH.'SALT.php');
|
||||||
$oZip->close();
|
$oArchive->close();
|
||||||
|
|
||||||
$data = \base64_encode(\file_get_contents($sZipFileName));
|
$data = \base64_encode(\file_get_contents($sFileName));
|
||||||
\unlink($sZipFileName);
|
\unlink($sFileName);
|
||||||
|
|
||||||
return $this->jsonResponse(__FUNCTION__, array(
|
return $this->jsonResponse(__FUNCTION__, array(
|
||||||
'zip' => $data
|
'zip' => $data
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var link = document.createElement("a");
|
var link = document.createElement("a");
|
||||||
link.download = 'backup-' + Date.now() + '.zip';
|
link.download = oData.Result.name;
|
||||||
link.href = 'data:application/zip;base64,' + oData.Result.zip;
|
link.href = oData.Result.data;
|
||||||
link.textContent = 'backup.zip';
|
link.textContent = oData.Result.name;
|
||||||
this.viewModelDom.append(link);
|
this.viewModelDom.append(link);
|
||||||
link.click();
|
link.click();
|
||||||
link.remove();
|
link.remove();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue