This commit is contained in:
Bozhidar 2024-05-02 23:06:52 +03:00
parent 70b51841eb
commit 4cc2fbb40d
4 changed files with 14 additions and 2 deletions

View file

@ -111,6 +111,7 @@ class Backup extends Model
}
if (count($errorsBag) > 0) {
$this->status = 'failed';
$this->backup_log = 'Backup failed. Database or env file missing.';
$this->save();
return [
'status' => 'failed',
@ -126,6 +127,7 @@ class Backup extends Model
if (count($errorsBag) > 0) {
$this->status = 'failed';
$this->backup_log = 'Backup failed. Database or env file content mismatch.';
$this->save();
return [
'status' => 'failed',
@ -145,6 +147,7 @@ class Backup extends Model
$this->status = 'completed';
$this->completed = true;
$this->completed_at = now();
$this->backup_log = 'Backup completed';
$this->save();
return [
@ -157,6 +160,7 @@ class Backup extends Model
if (Str::contains($checkProcess, $this->process_id)) {
$this->size = Helpers::checkPathSize($this->path);
$this->backup_log = 'Backup is still processing';
$this->save();
return [
@ -164,6 +168,7 @@ class Backup extends Model
'message' => 'Backup is still processing'
];
} else {
$this->backup_log = 'Backup failed. Process not found';
$this->status = 'failed';
$this->save();
return [

View file

@ -16,6 +16,7 @@ return new class extends Migration
$table->string('backup_type')->nullable();
$table->string('status')->nullable();
$table->string('backup_log')->nullable();
$table->string('path')->nullable();
$table->string('root_path')->nullable();

View file

@ -17,6 +17,7 @@ return new class extends Migration
$table->bigInteger('hosting_subscription_id')->nullable();
$table->string('backup_type')->nullable();
$table->string('status')->nullable();
$table->string('backup_log')->nullable();
$table->string('path')->nullable();
$table->string('root_path')->nullable();

View file

@ -30,7 +30,7 @@ class BackupTest extends ActionTestCase
$backupFinished = false;
for ($i = 0; $i < 400; $i++) {
for ($i = 0; $i < 100; $i++) {
Artisan::call('phyre:run-backup-checks');
@ -85,7 +85,7 @@ class BackupTest extends ActionTestCase
$findBackup = false;
$backupCompleted = false;
for ($i = 0; $i < 400; $i++) {
for ($i = 0; $i < 100; $i++) {
Artisan::call('phyre:run-backup-checks');
@ -98,6 +98,11 @@ class BackupTest extends ActionTestCase
sleep(1);
}
if (!$backupCompleted) {
$findBackup = Backup::where('id', $backupId)->first();
$this->fail('Backup not completed: '.$findBackup->backup_log);
}
$this->assertTrue($backupCompleted);
$this->assertNotEmpty($findBackup->file_path);
$this->assertTrue(file_exists($findBackup->file_path));