Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel9test #137

Merged
merged 11 commits into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/vendor
/tests/_report
/keystore
/packages
.vscode/
.env
.env.backup
Expand All @@ -16,3 +17,4 @@ npm-debug.log
yarn-error.log
modules_statuses.json
public/mix-manifest.json
version.txt
40 changes: 0 additions & 40 deletions app/Console/Commands/TbBackupCommand.php

This file was deleted.

58 changes: 58 additions & 0 deletions app/Console/Commands/TbMaintenanceBackupCommand.php
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;

class TbBackupDefaultCommand extends Command
class TbMaintenanceDefaultCommand extends Command
{
protected $signature = 'tb_backup:default {--confirmed} {--demo}';
protected $signature = 'tb_backup:default
{--confirmed : Run command without verification}
{--demo : Populate the database with random data for demonstration purpose}';
protected $description = 'Completely wipe all Tech Bench data and start from scratch';

/**
* Create a new command instance
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command
*/
Expand All @@ -36,6 +30,8 @@ public function handle()
return 0;
}

$this->warn('Defaulting Tech Bench');
$this->warn('Please wait...');
$this->call('down');
$this->callSilently('migrate:fresh');
$this->wipeFiles();
Expand All @@ -47,6 +43,7 @@ public function handle()
$this->callSilently('storage:link');

$this->info('Operation complete');
$this->info('You can log into the Tech Bench with the default username `admin` and default password `password`');
$this->call('up');
return 0;
}
Expand Down
Loading