dgd-backupper-php/app/Commands/BackupCommand.php

65 lines
1.6 KiB
PHP

<?php
namespace App\Commands;
use App\Utils\BackupManager;
use App\Utils\Builders\ContainerBuilder;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\Facades\Artisan;
use LaravelZero\Framework\Commands\Command;
class BackupCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'backup {containers*} {--data} {--mysql} {--upload}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Backup docker containers and all data.';
/**
* Execute the console command.
*
* @return mixed
* @throws \Throwable
*/
public function handle()
{
$containers = $this->argument('containers');
$this->line("<fg=red>### Backup is starting... ###</>");
$this->call("backup:container", [ 'containers' => $containers]);
if ($this->option('data')) {
$this->call("backup:data");
}
if ($this->option('mysql')) {
$this->call("backup:mysql", [
'--container' => env('MYSQL_CONTAINER_NAME'),
'--user' => env('MYSQL_USER'),
'--password' => env('MYSQL_PASSWORD'),
]);
}
$this->line("<fg=blue>|-> The backup and upload process is finished.</>");
return;
}
/**
* Define the command's schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
public function schedule(Schedule $schedule): void
{
// $schedule->command(static::class)->everyMinute();
}
}