-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from butcherman/laravel9test
Laravel9test
- Loading branch information
Showing
50 changed files
with
2,786 additions
and
1,279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class TbMaintenanceBackupCommand extends Command | ||
{ | ||
protected $signature = 'tb_maintenance:backup | ||
{--databaseOnly : Only backup the configuration database} | ||
{--filesOnly : Only backup the file system}'; | ||
protected $description = 'Generate a backup of the Tech Bench application'; | ||
|
||
/** | ||
* Execute the console command | ||
*/ | ||
public function handle() | ||
{ | ||
$this->line('Starting Application Backup'); | ||
$this->line('Please wait...'); | ||
|
||
Log::info('Starting Application Backup'); | ||
|
||
// Verify that no more than 70% of the HDD storage space has been used | ||
$freeSpace = disk_free_space('/app'); | ||
$totalSpace = disk_total_space('/app'); | ||
$usedSpace = $totalSpace - $freeSpace; | ||
$percentage = round(($usedSpace / $totalSpace * 100), 2); | ||
|
||
if($percentage > 70) | ||
{ | ||
Log::critical('Unable to backup file system, more than 70% of the available storage space in use'); | ||
$this->error('More than 70% of the file system is in use. Unable to backup file system at this time'); | ||
$this->error('Only backing up database '); | ||
$this->call('backup:run', ['--only-db' => true]); | ||
return 0; | ||
} | ||
|
||
if($this->option('databaseOnly')) | ||
{ | ||
$this->call('backup:run', ['--only-db' => true]); | ||
} | ||
elseif($this->option('filesOnly')) | ||
{ | ||
$this->call('backup:run', ['--only-files' => true]); | ||
} | ||
else | ||
{ | ||
$this->call('backup:run'); | ||
} | ||
|
||
Log::info('Application backup completed'); | ||
$this->info('Backup successful'); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.