diff --git a/web/app/Livewire/HostingSubscriptionBackupLog.php b/web/app/Livewire/HostingSubscriptionBackupLog.php index 5b3ba9b..d2dff1e 100644 --- a/web/app/Livewire/HostingSubscriptionBackupLog.php +++ b/web/app/Livewire/HostingSubscriptionBackupLog.php @@ -10,13 +10,14 @@ class HostingSubscriptionBackupLog extends Component public $backupLog; + public $backupLogFile = ''; + public function pullBackupLog() { - $findHsb = \App\Models\HostingSubscriptionBackup::where('id', $this->hostingSubscriptionBackupId)->first(); - if ($findHsb) { - $backupLog = $findHsb->path . '/backup.log'; - if (file_exists($backupLog)) { - $backupLogContent = file_get_contents($backupLog); + if ($this->backupLogFile) { + if (file_exists($this->backupLogFile)) { + + $backupLogContent = shell_exec('tail -n 1000 ' . $this->backupLogFile); // Get last 1000 lines of the log $backupLogContent = substr($backupLogContent, -5000, 5000); $backupLogContent = str_replace("\n", "
", $backupLogContent); @@ -25,9 +26,16 @@ class HostingSubscriptionBackupLog extends Component } } } + public function mount($hostingSubscriptionBackupId) { $this->hostingSubscriptionBackupId = $hostingSubscriptionBackupId; + + $findHsb = \App\Models\HostingSubscriptionBackup::where('id', $this->hostingSubscriptionBackupId)->first(); + if ($findHsb) { + $this->backupLogFile = $findHsb->path . '/backup.log'; + $this->pullBackupLog(); + } } public function render() diff --git a/web/app/Models/HostingSubscriptionBackup.php b/web/app/Models/HostingSubscriptionBackup.php index 1e2bffe..9b8dc49 100644 --- a/web/app/Models/HostingSubscriptionBackup.php +++ b/web/app/Models/HostingSubscriptionBackup.php @@ -227,7 +227,7 @@ class HostingSubscriptionBackup extends Model } // With find, we can search for all files,directories (including hidden) in the current directory and zip them - $shellFileContent .= 'cd '.$backupTempPath .' && find . -exec zip -r '.$backupFilePath.' {} \;'. PHP_EOL; + $shellFileContent .= 'cd '.$backupTempPath .' && find . -exec zip --symlinks -r '.$backupFilePath.' {} \;'. PHP_EOL; $shellFileContent .= 'rm -rf '.$backupTempPath.PHP_EOL; $shellFileContent .= 'echo "Backup complete"' . PHP_EOL;