mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-25 09:00:27 +00:00
updateupdate
This commit is contained in:
parent
75807c3aaf
commit
8950a33bb4
3 changed files with 29 additions and 6 deletions
|
@ -52,8 +52,8 @@ class RunBackup extends Command
|
|||
$backup->status = 'pending';
|
||||
$backup->save();
|
||||
} else {
|
||||
$this->info('Backup already exists for ' . $hostingSubscription->domain);
|
||||
$this->info('Created before: ' . $findBackup->created_at->diffForHumans());
|
||||
$this->error('Backup already exists for ' . $hostingSubscription->domain);
|
||||
$this->error('Created before: ' . $findBackup->created_at->diffForHumans());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ class RunBackup extends Command
|
|||
if ($getPendingBackups->count() > 0) {
|
||||
foreach ($getPendingBackups as $pendingBackup) {
|
||||
$pendingBackup->startBackup();
|
||||
$this->info('Backup started.. ');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +73,7 @@ class RunBackup extends Command
|
|||
if ($getRunningBackups->count() > 0) {
|
||||
foreach ($getRunningBackups as $runningBackup) {
|
||||
$runningBackup->checkBackup();
|
||||
$this->info('Checking backup status...');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Enums\BackupStatus;
|
||||
use App\Filament\Enums\BackupType;
|
||||
use App\Filament\Resources\BackupResource\Pages;
|
||||
use app\Filament\Resources\BackupResource\Widgets\BackupStats;
|
||||
|
@ -65,6 +66,7 @@ class BackupResource extends Resource
|
|||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('process_id'),
|
||||
Tables\Columns\TextColumn::make('backup_type'),
|
||||
Tables\Columns\TextColumn::make('backupRelated'),
|
||||
Tables\Columns\BadgeColumn::make('status')
|
||||
|
|
|
@ -77,7 +77,8 @@ class Backup extends Model
|
|||
|
||||
public function checkBackup()
|
||||
{
|
||||
if ($this->status == 'processing') {
|
||||
if ($this->status == BackupStatus::Processing) {
|
||||
|
||||
$backupDoneFile = $this->path.'/backup.done';
|
||||
if (file_exists($backupDoneFile)) {
|
||||
$this->size = filesize($this->filepath);
|
||||
|
@ -85,14 +86,32 @@ class Backup extends Model
|
|||
$this->completed = true;
|
||||
$this->completed_at = now();
|
||||
$this->save();
|
||||
return [
|
||||
'status' => 'completed',
|
||||
'message' => 'Backup completed'
|
||||
];
|
||||
}
|
||||
|
||||
$checkProcess = shell_exec('ps -p ' . $this->process_id . ' | grep ' . $this->process_id);
|
||||
if (Str::contains($checkProcess, $this->process_id)) {
|
||||
return [
|
||||
'status' => 'processing',
|
||||
'message' => 'Backup is still processing'
|
||||
];
|
||||
} else {
|
||||
$this->status = 'failed';
|
||||
$this->save();
|
||||
return [
|
||||
'status' => 'failed',
|
||||
'message' => 'Backup failed'
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startBackup()
|
||||
{
|
||||
|
||||
if ($this->status == 'processing') {
|
||||
if ($this->status == BackupStatus::Processing) {
|
||||
return [
|
||||
'status' => 'processing',
|
||||
'message' => 'Backup is already processing'
|
||||
|
@ -138,7 +157,7 @@ class Backup extends Model
|
|||
|
||||
$pid = shell_exec('bash '.$backupTempScript.' >> ' . $backupLogFilePath . ' & echo $!');
|
||||
$pid = intval($pid);
|
||||
|
||||
|
||||
if ($pid > 0 && is_numeric($pid)) {
|
||||
|
||||
$this->path = $backupPath;
|
||||
|
|
Loading…
Reference in a new issue