Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Apr 25, 2024
1 parent 6c9016a commit 071a519
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions web/app/Models/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function boot()
});
}

private function checkCronJob()
public function checkCronJob()
{
$cronJobCommand = 'phyre-php /usr/local/phyre/web/artisan phyre:run-backup';
$findCronJob = CronJob::where('command', $cronJobCommand)->first();
Expand All @@ -63,7 +63,9 @@ private function checkCronJob()
$cronJob->command = $cronJobCommand;
$cronJob->user = 'root';
$cronJob->save();
return false;
}
return true;
}

protected function backupRelated() : Attribute
Expand Down Expand Up @@ -144,7 +146,7 @@ public function startBackup()
$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';
Expand Down
5 changes: 5 additions & 0 deletions web/tests/Unit/BackupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -75,6 +79,7 @@ public function testBackup()
$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'));


}

}

0 comments on commit 071a519

Please sign in to comment.