10-26-2010, 05:13 PM
Hello
There is a problem with "Human readable archive". TAR accept only filename with 100 characters.
Then i'm modified code to create a ZIP file.
This function can be used for classic backup (not tested)
In the file "op.CreateFolderArchive.php"
Add this function
There is a problem with "Human readable archive". TAR accept only filename with 100 characters.
Then i'm modified code to create a ZIP file.
This function can be used for classic backup (not tested)
In the file "op.CreateFolderArchive.php"
Add this function
PHP Code:
<?php
function createFolderZIP($folder, $zip)
{
global $settings,$human_readable;
$documents=$folder->getDocuments();
foreach ($documents as $document){
if (file_exists($settings->_contentDir.$document->getDir())){
if ($human_readable){
// create an archive containing the files with original names and DMS path
// thanks to Doudoux
$latestContent = $document->getLatestContent();
if (is_object($latestContent))
{
$zip->addFile(
$settings->_contentDir.$latestContent->getDir().$latestContent->getVersion().$latestContent->getFileType(),
getFolderPathPlainAST($folder)."/".$document->getID()."_".mydmsDecodeString($latestContent->getOriginalFileName()));
}
}else{
// create a server backup archive
$handle = opendir($settings->_contentDir.$document->getDir());
while ($entry = readdir($handle) )
{
if (!is_dir($settings->_contentDir.$document->getDir().$entry)){
$zip->addFile($settings->_contentDir.$document->getDir().$entry,$document->getDir().$entry);
}
}
closedir($handle);
}
}
}
$subFolders=$folder->getSubfolders();
foreach ($subFolders as $folder)
if (!createFolderZIP($folder, $zip))
return false;
return true;
}
Change
PHP Code:
<?php
if ($human_readable)$ark_name = $settings->_contentDir.time()."_".$folderid."_HR.tar";
else $ark_name = $settings->_contentDir.time()."_".$folderid.".tar";
$ark = fopen($ark_name,"w");
if (!createFolderTar($folder,$ark)) {
fclose($ark);
unlink($ark_name);
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
TarAddFooter($ark);
fclose($ark);
if (gzcompressfile($ark_name,9)) unlink($ark_name);
else UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));

