&1', 'r'); if ($handle === false) return 1; while (!feof($handle)) { $chunk = fread($handle, 256); if ($chunk !== false && $chunk !== '') { echo $chunk; flush(); } } return pclose($handle); } echo "=== Backup ===\n"; flush(); $exit = stream("SNAPSHOT_KEEP={$SNAPSHOT_KEEP} {$BACKUP_SCRIPT} {$BASE_DIR} /"); if ($exit !== 0) { echo "\n[FEHLER] Backup fehlgeschlagen (exit {$exit})\n"; exit; } // Web-gelöschte Dateien wieder entfernen (kommen durch Sync zurück) $excludeFile = $BASE_DIR . '/.web_deleted'; if (file_exists($excludeFile)) { $lines = file($excludeFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $removed = 0; foreach (array_unique($lines) as $p) { $p = '/' . ltrim($p, '/'); $local = $BASE_DIR . '/current' . $p; if (is_dir($local)) { shell_exec('rm -rf ' . escapeshellarg($local)); $removed++; } else { foreach ([$local, $local.'.pdf', $local.'.rmdoc', $local.'.thumb.jpg'] as $f) { if (is_file($f) && @unlink($f)) $removed++; } } } if ($removed) echo "\n[Web-Löschung] $removed Element(e) erneut entfernt.\n"; } echo "\n=== PDF-Konvertierung ===\n"; flush(); stream("{$CONVERT_SCRIPT} {$BASE_DIR}/current"); echo "\n=== Fertig ===\n";