This commit is contained in:
Bozhidar 2024-04-25 15:38:39 +03:00
parent 6c9016ae0c
commit 071a519db5
2 changed files with 9 additions and 2 deletions

View file

@ -53,7 +53,7 @@ class Backup extends Model
});
}
private function checkCronJob()
public function checkCronJob()
{
$cronJobCommand = 'phyre-php /usr/local/phyre/web/artisan phyre:run-backup';
$findCronJob = CronJob::where('command', $cronJobCommand)->first();
@ -63,7 +63,9 @@ class Backup extends Model
$cronJob->command = $cronJobCommand;
$cronJob->user = 'root';
$cronJob->save();
return false;
}
return true;
}
protected function backupRelated() : Attribute
@ -144,7 +146,7 @@ class Backup extends Model
$findHostingSubscription = HostingSubscription::where('id', $this->hosting_subscription_id)->first();
if ($findHostingSubscription) {
$backupFileName = Str::slug($findHostingSubscription->domain .'-'. date('Ymd-His')) . '.tar.gz';
$backupFileName = Str::slug($findHostingSubscription->system_username .'-'. date('Ymd-His')) . '.tar.gz';
$backupFilePath = $backupPath.'/'.$backupFileName;
$backupLogFileName = 'backup.log';

View file

@ -15,6 +15,10 @@ class BackupTest extends ActionTestCase
{
public function testBackup()
{
$backup = new Backup();
$checkCronJob = $backup->checkCronJob();
$this->assertTrue($checkCronJob);
$customer = new Customer();
$customer->name = 'UnitBackupTest' . time();
$customer->email = 'UnitBackupTest' . time() . '@unit-test.com';
@ -75,6 +79,7 @@ class BackupTest extends ActionTestCase
$this->assertTrue(is_dir($findBackup->path . '/unit-test/' . $hostingSubscription->system_username . '/public_html/cgi-bin'));
$this->assertTrue(is_file($findBackup->path . '/unit-test/' . $hostingSubscription->system_username . '/public_html/index.php'));
}
}