Compare commits

..

No commits in common. "b4e809c61b3103054f9fd9ef4171d0e8c08ae06c" and "5cb8e1619125afb17d0316a97951732bb4fefe90" have entirely different histories.

4 changed files with 3 additions and 64 deletions

View File

@ -1,16 +0,0 @@
kind: pipeline
name: default
type: docker
steps:
- name: composer
pull: if-not-exists
image: composer
commands:
- composer install --prefer-dist
- name: test
image: lorisleiva/laravel-docker
commands:
- ./vendor/bin/phpunit

View File

@ -15,7 +15,7 @@ class DataBackupCommand extends Command
*
* @var string
*/
protected $signature = 'backup:data {--dataFolder=} {--backupFolder=} {--clean}';
protected $signature = 'backup:data {--dataFolder=} {--backupFolder=}';
/**
* The description of the command.
@ -34,16 +34,11 @@ class DataBackupCommand extends Command
{
$backupFolder = $this->option('backupFolder');
$dataFolder = $this->option('dataFolder');
$clean = $this->option('clean');
$this->line("<fg=blue>|-> Backing up data folder...</>");
$bm = new BackupManager();
$this->line("<fg=blue>|-> Backing up data folder...</>");
$builder = new DataBuilder();
$builder->setDataFolder($dataFolder)
->setBackupFolder($backupFolder)
->setClean($clean);
$builder->setDataFolder($dataFolder)->setBackupFolder($backupFolder);
$bm->setBuilder($builder)->execute();
if ($bm->getShell()->getReturnValue() == 0) {
$this->line("<fg=green> |-> Data folder successfully backed up.</>");
} else {

View File

@ -1,8 +0,0 @@
<?php
namespace App\Exceptions;
class CleanException extends \Exception
{
}

View File

@ -4,36 +4,12 @@ namespace App\Utils;
use \AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;
use App\Exceptions\BackupFolderNotFoundException;
use App\Exceptions\CleanException;
use Throwable;
abstract class Builder
{
private $backupFolder;
private $containerName;
private $clean;
/**
* Builder constructor.
*/
public function __construct()
{
$this->clean = false;
}
public function __destruct()
{
try {
if ($this->clean) {
$files = glob($this->backupFolder . '/*');
foreach($files as $file){
is_file($file) ? unlink($file) : null;
}
}
} catch (\Exception $exception) {
throw new CleanException($exception->getMessage());
}
}
/**
* @param $backupFolder
@ -73,14 +49,6 @@ abstract class Builder
return $this->containerName;
}
/**
* @param bool $clean
*/
public function setClean(bool $clean): void
{
$this->clean = $clean;
}
/**
* @return CommandBuilder
*/