public function fileStep($step)
{
$filesContainer = $this->getFilesToBackup();
$files = $filesContainer[$step];
$excludePatterns = [PIMCORE_FRONTEND_MODULE . "/var/backup/.*", PIMCORE_FRONTEND_MODULE . "/var/cache/.*", PIMCORE_FRONTEND_MODULE . "/var/log/.*", PIMCORE_FRONTEND_MODULE . "/var/system/.*", PIMCORE_FRONTEND_MODULE . "/var/tmp/.*", PIMCORE_FRONTEND_MODULE . "/var/webdav/.*"];
if (!empty($this->additionalExcludePatterns) && is_array($this->additionalExcludePatterns)) {
$excludePatterns = array_merge($excludePatterns, $this->additionalExcludePatterns);
}
foreach ($excludePatterns as &$excludePattern) {
$excludePattern = "@" . $excludePattern . "@";
}
clearstatcache();
foreach ($files as $file) {
if ($file) {
if (file_exists($file) && is_readable($file)) {
$exclude = false;
$relPath = str_replace(PIMCORE_DOCUMENT_ROOT, "", $file);
$relPath = str_replace(DIRECTORY_SEPARATOR, "/", $relPath);
// windows compatibility
foreach ($excludePatterns as $pattern) {
if (preg_match($pattern, $relPath)) {
$exclude = true;
}
}
if (!$exclude && is_file($file)) {
$this->getArchive()->addFile($file, ltrim($relPath, "/"));
} else {
Logger::info("Backup: Excluded: " . $file);
}
} else {
Logger::err("Backup: Can't read file: " . $file);
}
}
}
$this->setFileAmount($this->getFileAmount() + count($files));
return ["success" => true, "filesize" => $this->getFormattedFilesize(), "fileAmount" => $this->getFileAmount()];
}