This commit is contained in:
Bozhidar 2024-05-10 17:13:25 +03:00
parent e82d70fb3a
commit aef89cc325
2 changed files with 14 additions and 6 deletions

View file

@ -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", "<br>", $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()

View file

@ -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;