diff --git a/web/app/Console/Commands/RunBackup.php b/web/app/Console/Commands/RunBackup.php index bd325be..bd4fcc3 100644 --- a/web/app/Console/Commands/RunBackup.php +++ b/web/app/Console/Commands/RunBackup.php @@ -42,7 +42,7 @@ class RunBackup extends Command if ($getPendingBackups->count() > 0) { if ($getPendingBackups->count() > 1) { - $this->info('Multiple backups are pending..'); + $this->info('Multiple backups are pending...'); } else { foreach ($getPendingBackups as $pendingBackup) { $pendingBackup->startBackup(); diff --git a/web/app/Console/Commands/RunHostingSubscriptionsBackup.php b/web/app/Console/Commands/RunHostingSubscriptionsBackup.php index 9924b70..80b472c 100644 --- a/web/app/Console/Commands/RunHostingSubscriptionsBackup.php +++ b/web/app/Console/Commands/RunHostingSubscriptionsBackup.php @@ -17,7 +17,7 @@ class RunHostingSubscriptionsBackup extends Command * * @var string */ - protected $signature = 'phyre:run-hosting-subscriptions-backup'; + protected $signature = 'phyre:run-hosting-subscriptions-backup-checks'; /** * The console command description. @@ -37,26 +37,26 @@ class RunHostingSubscriptionsBackup extends Command $backup->delete(); } - // Find Hosting Subscriptions - $findHostingSubscriptions = HostingSubscription::all(); - if ($findHostingSubscriptions->count() > 0) { - foreach ($findHostingSubscriptions as $hostingSubscription) { - - $findBackup = HostingSubscriptionBackup::where('hosting_subscription_id', $hostingSubscription->id) - ->where('backup_type', 'full') - ->where('created_at', '>=', Carbon::now()->subHours(24)) - ->first(); - if (! $findBackup) { - $backup = new HostingSubscriptionBackup(); - $backup->hosting_subscription_id = $hostingSubscription->id; - $backup->backup_type = 'full'; - $backup->save(); - } else { - $this->error('Backup already exists for ' . $hostingSubscription->domain); - $this->error('Created before: ' . $findBackup->created_at->diffForHumans()); - } - } - } +// // Find Hosting Subscriptions +// $findHostingSubscriptions = HostingSubscription::all(); +// if ($findHostingSubscriptions->count() > 0) { +// foreach ($findHostingSubscriptions as $hostingSubscription) { +// +// $findBackup = HostingSubscriptionBackup::where('hosting_subscription_id', $hostingSubscription->id) +// ->where('backup_type', 'full') +// ->where('created_at', '>=', Carbon::now()->subHours(24)) +// ->first(); +// if (! $findBackup) { +// $backup = new HostingSubscriptionBackup(); +// $backup->hosting_subscription_id = $hostingSubscription->id; +// $backup->backup_type = 'full'; +// $backup->save(); +// } else { +// $this->error('Backup already exists for ' . $hostingSubscription->domain); +// $this->error('Created before: ' . $findBackup->created_at->diffForHumans()); +// } +// } +// } // Check for pending backups @@ -64,8 +64,8 @@ class RunHostingSubscriptionsBackup extends Command ->get(); if ($getPendingBackups->count() > 0) { - if ($getPendingBackups->count() > 3) { - $this->info('There are more than 3 pending backups. Please wait for them to finish.'); + if ($getPendingBackups->count() > 1) { + $this->info('Multiple backups are pending...'); } else { foreach ($getPendingBackups as $pendingBackup) { $pendingBackup->startBackup(); diff --git a/web/app/Filament/Resources/HostingPlanResource.php b/web/app/Filament/Resources/HostingPlanResource.php index 8600b3e..e05c071 100644 --- a/web/app/Filament/Resources/HostingPlanResource.php +++ b/web/app/Filament/Resources/HostingPlanResource.php @@ -7,6 +7,7 @@ use App\Filament\Resources\HostingPlanResource\Pages; use App\Models\HostingPlan; use App\Models\RemoteDatabaseServer; use App\SupportedApplicationTypes; +use Filament\Actions\DeleteAction; use Filament\Forms; use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\Select; @@ -250,6 +251,7 @@ class HostingPlanResource extends Resource ]) ->actions([ Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make() ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ diff --git a/web/app/Models/HostingSubscriptionBackup.php b/web/app/Models/HostingSubscriptionBackup.php index 1a6c097..4b84d73 100644 --- a/web/app/Models/HostingSubscriptionBackup.php +++ b/web/app/Models/HostingSubscriptionBackup.php @@ -65,7 +65,7 @@ class HostingSubscriptionBackup extends Model public function checkCronJob() { - $cronJobCommand = 'phyre-php /usr/local/phyre/web/artisan phyre:run-hosting-subscriptions-backup'; + $cronJobCommand = 'phyre-php /usr/local/phyre/web/artisan phyre:run-hosting-subscriptions-backup-checks'; $findCronJob = CronJob::where('command', $cronJobCommand)->first(); if (! $findCronJob) { $cronJob = new CronJob(); @@ -73,8 +73,18 @@ class HostingSubscriptionBackup extends Model $cronJob->command = $cronJobCommand; $cronJob->user = 'root'; $cronJob->save(); - return false; } + + $cronJobCommand = 'phyre-php /usr/local/phyre/web/artisan phyre:create-daily-full-hosting-subscriptions-backup'; + $findCronJob = CronJob::where('command', $cronJobCommand)->first(); + if (! $findCronJob) { + $cronJob = new CronJob(); + $cronJob->schedule = '0 0 * * *'; + $cronJob->command = $cronJobCommand; + $cronJob->user = 'root'; + $cronJob->save(); + } + return true; }