loadConfiguration(); } public function getList(): array { $backups = []; try { $backupDir = $this->jarPath . '/backup'; if (! is_dir($backupDir)) { return $backups; } $result = Process::timeout(5)->run("ls -1t {$backupDir}/*.jar 2>/dev/null"); if ($result->successful()) { $lines = array_filter(explode("\n", trim($result->output()))); foreach ($lines as $line) { $line = trim($line); if ($line === '' || $line === '0' || ! str_contains($line, '.jar')) { continue; } $filename = basename($line); $version = $this->extractVersionFromFilename($filename); preg_match('/(\d{4}-\d{2}-\d{2}_\d{2}-\d{2})/', $line, $dateMatches); $date = $dateMatches[1] ?? date('Y-m-d_H-i'); $backups[] = [ 'name' => $filename, 'jar' => $filename, 'date' => $date, 'version' => $version, ]; } } } catch (\Exception) { } return $backups; } public function restore(string $backupName): array { try { $backupDir = $this->jarPath . '/backup'; $backupPath = $backupDir . '/' . $backupName; $targetPath = $this->jarPath . '/' . $backupName; if (! file_exists($backupPath)) { return ['success' => false, 'error' => 'Backup niet gevonden']; } if (file_exists($targetPath)) { unlink($targetPath); } copy($backupPath, $targetPath); chmod($targetPath, 0755); return ['success' => true, 'message' => 'Backup hersteld: ' . $backupName]; } catch (\Exception $e) { return ['success' => false, 'error' => $e->getMessage()]; } } }