PhyrePanel-mirror/web/app/Livewire/BackupLog.php

47 lines
1.1 KiB
PHP
Raw Normal View History

2024-05-09 12:44:00 +00:00
<?php
namespace App\Livewire;
use Livewire\Component;
class BackupLog extends Component
{
public $backupId;
public $backupLog;
2024-05-10 13:29:17 +00:00
public $backupLogFile = '';
2024-05-09 12:44:00 +00:00
public function pullBackupLog()
{
2024-05-10 13:23:20 +00:00
2024-05-10 13:29:17 +00:00
if ($this->backupLogFile) {
if (file_exists($this->backupLogFile)) {
$backupLogContent = shell_exec('tail -n 1000 ' . $this->backupLogFile);
2024-05-09 12:44:00 +00:00
// Get last 1000 lines of the log
$backupLogContent = substr($backupLogContent, -5000, 5000);
$backupLogContent = str_replace("\n", "<br>", $backupLogContent);
$this->backupLog = $backupLogContent;
}
}
2024-05-10 13:29:17 +00:00
2024-05-09 12:44:00 +00:00
}
public function mount($backupId)
{
$this->backupId = $backupId;
2024-05-10 13:29:17 +00:00
$findBackup = \App\Models\Backup::where('id', $this->backupId)->first();
if ($findBackup) {
$this->backupLogFile = $findBackup->path . '/backup.log';
$this->pullBackupLog();
}
2024-05-09 12:44:00 +00:00
}
public function render()
{
return view('livewire.hosting-subscription-backup-log');
}
}