diff --git a/app/Commands/InspiringCommand.php b/app/Commands/AboutCommand.php similarity index 50% rename from app/Commands/InspiringCommand.php rename to app/Commands/AboutCommand.php index 52b4d5b..a2f113c 100644 --- a/app/Commands/InspiringCommand.php +++ b/app/Commands/AboutCommand.php @@ -5,21 +5,21 @@ namespace App\Commands; use Illuminate\Console\Scheduling\Schedule; use LaravelZero\Framework\Commands\Command; -class InspiringCommand extends Command +class AboutCommand extends Command { /** * The signature of the command. * * @var string */ - protected $signature = 'inspiring {name=Artisan}'; + protected $signature = 'about'; /** * The description of the command. * * @var string */ - protected $description = 'Display an inspiring quote'; + protected $description = 'Display about message'; /** * Execute the console command. @@ -28,7 +28,12 @@ class InspiringCommand extends Command */ public function handle() { - $this->info('Simplicity is the ultimate sophistication.'); + $this->line("Backup manager for backing up Docker Containers to Mega.nz."); + $this->line("Developer: Muhep Atasoy"); + $this->line("Github: https://github.com/muhep06"); + $this->line("Gitea: https://git.muhepatasoy.xyz/muhep"); + $this->line("Drone: https://drone.muhepatasoy.xyz/muhep/dgd-backupper-php"); + return; } /** @@ -37,7 +42,7 @@ class InspiringCommand extends Command * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ - public function schedule(Schedule $schedule) + public function schedule(Schedule $schedule): void { // $schedule->command(static::class)->everyMinute(); } diff --git a/app/Commands/BackupCommand.php b/app/Commands/BackupCommand.php index 066d272..b2ce5b5 100644 --- a/app/Commands/BackupCommand.php +++ b/app/Commands/BackupCommand.php @@ -2,10 +2,7 @@ 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 diff --git a/app/Commands/ContainerBackupCommand.php b/app/Commands/ContainerBackupCommand.php index c8a6229..3a1afe7 100644 --- a/app/Commands/ContainerBackupCommand.php +++ b/app/Commands/ContainerBackupCommand.php @@ -15,7 +15,9 @@ class ContainerBackupCommand extends Command * * @var string */ - protected $signature = 'backup:container {containers*}'; + protected $signature = 'backup:container + {containers* : Name or ID of the containers to be backed up.} + {--folder= : Export folder for backed up containers.}'; /** * The description of the command. @@ -33,8 +35,13 @@ class ContainerBackupCommand extends Command public function handle() { $containers = $this->argument('containers'); + $backupFolder = $this->option('folder'); + if (!$backupFolder) { + $backupFolder = env('BACKUP_FOLDER'); + } + $backupManager = new BackupManager(); - $backupManager->setBackupFolder(env('BACKUP_FOLDER')); + $backupManager->setBackupFolder($backupFolder); foreach ($containers as $container) { $this->line("|-> Backing up {$container}..."); $builder = new ContainerBuilder(); diff --git a/app/Commands/DataBackupCommand.php b/app/Commands/DataBackupCommand.php index d2abd96..f7cb3fa 100644 --- a/app/Commands/DataBackupCommand.php +++ b/app/Commands/DataBackupCommand.php @@ -15,7 +15,9 @@ class DataBackupCommand extends Command * * @var string */ - protected $signature = 'backup:data'; + protected $signature = 'backup:data + {--data= : You can use it to back up the data folder of all containers or any folder. } + {--folder= : Export folder for backed up folder. }'; /** * The description of the command. @@ -34,10 +36,19 @@ class DataBackupCommand extends Command { $this->line("|-> Backing up data folder..."); + $backupFolder = $this->option('folder'); + $dataFolder = $this->option('data'); + if (!$backupFolder) { + $backupFolder = env('BACKUP_FOLDER'); + } + if (!$dataFolder) { + $dataFolder = env('DATA_FOLDER'); + } + $bm = new BackupManager(); $builder = new DataBuilder(); - $builder->setDataFolder(env('DATA_FOLDER')); - $bm->setBackupFolder(env('BACKUP_FOLDER')) + $builder->setDataFolder($dataFolder); + $bm->setBackupFolder($backupFolder) ->setBuilder($builder)->execute(); if ($bm->getShell()->getReturnValue() == 0) { diff --git a/app/Commands/MysqlBackupCommand.php b/app/Commands/MysqlBackupCommand.php index 83a88d4..53356a6 100644 --- a/app/Commands/MysqlBackupCommand.php +++ b/app/Commands/MysqlBackupCommand.php @@ -15,7 +15,11 @@ class MysqlBackupCommand extends Command * * @var string */ - protected $signature = 'backup:mysql {--container=} {--user=} {--password=}'; + protected $signature = 'backup:mysql + {--container= : Mysql container name or id} + {--user= : Mysql username} + {--password= : Mysql password} + {--folder= : Export folder for backup}'; /** * The description of the command. @@ -46,7 +50,12 @@ class MysqlBackupCommand extends Command $builder->setCredential($credentials); $builder->setContainerName($container); - $bm->setBackupFolder(env('BACKUP_FOLDER')) + $backupFolder = $this->option('folder'); + if (!$backupFolder) { + $backupFolder = env('BACKUP_FOLDER'); + } + + $bm->setBackupFolder($backupFolder) ->setBuilder($builder)->execute(); if ($bm->getShell()->getReturnValue() == 0) { diff --git a/tests/Feature/InspiringCommandTest.php b/tests/Feature/InspiringCommandTest.php index 358e77b..1854bed 100644 --- a/tests/Feature/InspiringCommandTest.php +++ b/tests/Feature/InspiringCommandTest.php @@ -13,7 +13,7 @@ class InspiringCommandTest extends TestCase */ public function testInspiringCommand() { - $this->artisan('inspiring') + $this->artisan('about') ->expectsOutput('Simplicity is the ultimate sophistication.') ->assertExitCode(0); }