Compare commits
6 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
ea566de865 | |
|
|
ed02258674 | |
|
|
c38a444db6 | |
|
|
a2f1302a67 | |
|
|
2b7ab97ce8 | |
|
|
5bedb3f9fa |
|
|
@ -0,0 +1,7 @@
|
||||||
|
BACKUP_FOLDER=/root/backup
|
||||||
|
EXPORT_FOLDER=/root/export
|
||||||
|
TARGET_FOLDER=/backup
|
||||||
|
DATA_FOLDER=/root/git/home
|
||||||
|
MYSQL_CONTAINER_NAME=mysql
|
||||||
|
MYSQL_USER=root
|
||||||
|
MYSQL_PASSWORD=secret
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Muhep Atasoy
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
36
README.md
36
README.md
|
|
@ -1,37 +1,9 @@
|
||||||
<p align="center">
|
# Backupper
|
||||||
<img title="Laravel Zero" height="100" src="https://raw.githubusercontent.com/laravel-zero/docs/master/images/logo/laravel-zero-readme.png" />
|
Backup manager for backing up Docker Containers to Mega.nz.
|
||||||
</p>
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<a href="https://travis-ci.org/laravel-zero/framework"><img src="https://img.shields.io/travis/laravel-zero/framework/stable.svg" alt="Build Status"></img></a>
|
|
||||||
<a href="https://scrutinizer-ci.com/g/laravel-zero/framework"><img src="https://img.shields.io/scrutinizer/g/laravel-zero/framework.svg" alt="Quality Score"></img></a>
|
|
||||||
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/d/total.svg" alt="Total Downloads"></a>
|
|
||||||
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/v/stable.svg" alt="Latest Stable Version"></a>
|
|
||||||
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/license.svg" alt="License"></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h4> <center>This is a <bold>community project</bold> and not an official Laravel one </center></h4>
|
|
||||||
|
|
||||||
Laravel Zero was created by, and is maintained by [Nuno Maduro](https://github.com/nunomaduro), and is a micro-framework that provides an elegant starting point for your console application. It is an **unofficial** and customized version of Laravel optimized for building command-line applications.
|
|
||||||
|
|
||||||
- Built on top of the [Laravel](https://laravel.com) components.
|
|
||||||
- Optional installation of Laravel [Eloquent](https://laravel-zero.com/docs/database/), Laravel [Logging](https://laravel-zero.com/docs/logging/) and many others.
|
|
||||||
- Supports interactive [menus](https://laravel-zero.com/docs/build-interactive-menus/) and [desktop notifications](https://laravel-zero.com/docs/send-desktop-notifications/) on Linux, Windows & MacOS.
|
|
||||||
- Ships with a [Scheduler](https://laravel-zero.com/docs/task-scheduling/) and a [Standalone Compiler](https://laravel-zero.com/docs/build-a-standalone-application/).
|
|
||||||
- Integration with [Collision](https://github.com/nunomaduro/collision) - Beautiful error reporting
|
|
||||||
|
|
||||||
------
|
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
For full documentation, visit [laravel-zero.com](https://laravel-zero.com/).
|
For full documentation, visit [Wiki](https://github.com/muhep06/dgd-backupper-php/wiki).
|
||||||
|
|
||||||
## Support the development
|
|
||||||
**Do you like this project? Support it by donating**
|
|
||||||
|
|
||||||
- PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L)
|
|
||||||
- Patreon: [Donate](https://www.patreon.com/nunomaduro)
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
Backupper is an open-source software licensed under the [MIT license](https://github.com/muhep06/dgd-backupper-php/blob/master/LICENSE).
|
||||||
Laravel Zero is an open-source software licensed under the [MIT license](https://github.com/laravel-zero/laravel-zero/blob/stable/LICENSE.md).
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class BackupCommand extends Command
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'backup {containers*} {--data} {--mysql} {--upload} {--clean}';
|
protected $signature = 'backup {containers*} {--data} {--mysql} {--pack} {--upload} {--clean}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The description of the command.
|
* The description of the command.
|
||||||
|
|
@ -38,18 +38,40 @@ class BackupCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->option('mysql')) {
|
if ($this->option('mysql')) {
|
||||||
$this->call("backup:mysql", [
|
$this->call("backup:mysql");
|
||||||
'--container' => env('MYSQL_CONTAINER_NAME'),
|
}
|
||||||
'--user' => env('MYSQL_USER'),
|
|
||||||
'--password' => env('MYSQL_PASSWORD'),
|
date_default_timezone_set('Europe/Istanbul');
|
||||||
|
$date = date('d-m-Y_H-i-s', time());
|
||||||
|
|
||||||
|
if ($this->option('pack')) {
|
||||||
|
$this->call('backup:pack', [
|
||||||
|
'name' => 'backup_' . $date,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->option('upload')) {
|
||||||
|
if (!$this->option('pack')) {
|
||||||
|
$this->call('backup:pack', [
|
||||||
|
'name' => 'backup_' . $date,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$this->call("backup:upload", [
|
||||||
|
'name' => 'backup_' . $date . '.tar.gz',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->option('clean')) {
|
if ($this->option('clean')) {
|
||||||
|
$this->line("<fg=yellow>|-> Cleaning...</>");
|
||||||
$files = glob(env('BACKUP_FOLDER') . '/*');
|
$files = glob(env('BACKUP_FOLDER') . '/*');
|
||||||
foreach($files as $file){
|
foreach($files as $file){
|
||||||
is_file($file) ? unlink($file) : null;
|
is_file($file) ? unlink($file) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$files = glob(env('EXPORT_FOLDER') . '/*');
|
||||||
|
foreach($files as $file){
|
||||||
|
is_file($file) ? unlink($file) : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->line("<fg=blue>|-> The backup and upload process is finished.</>");
|
$this->line("<fg=blue>|-> The backup and upload process is finished.</>");
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,11 @@ class ContainerBackupCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$backupManager = new BackupManager();
|
$backupManager = new BackupManager();
|
||||||
$backupManager->setBackupFolder($backupFolder);
|
|
||||||
foreach ($containers as $container) {
|
foreach ($containers as $container) {
|
||||||
$this->line("<fg=blue>|-> Backing up {$container}...</>");
|
$this->line("<fg=blue>|-> Backing up {$container}...</>");
|
||||||
$builder = new ContainerBuilder();
|
$builder = new ContainerBuilder();
|
||||||
$builder->setContainerName($container);
|
$builder->setContainerName($container)
|
||||||
|
->setBackupFolder($backupFolder);
|
||||||
$backupManager->setBuilder($builder)->execute();
|
$backupManager->setBuilder($builder)->execute();
|
||||||
if ($backupManager->getShell()->getReturnValue() == 0) {
|
if ($backupManager->getShell()->getReturnValue() == 0) {
|
||||||
$this->line("<fg=green> |-> {$container} successfully backed up.</>");
|
$this->line("<fg=green> |-> {$container} successfully backed up.</>");
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,12 @@ class DataBackupCommand extends Command
|
||||||
$dataFolder = env('DATA_FOLDER');
|
$dataFolder = env('DATA_FOLDER');
|
||||||
}
|
}
|
||||||
|
|
||||||
$bm = new BackupManager();
|
|
||||||
$builder = new DataBuilder();
|
$builder = new DataBuilder();
|
||||||
$builder->setDataFolder($dataFolder);
|
$builder->setDataFolder($dataFolder)
|
||||||
$bm->setBackupFolder($backupFolder)
|
->setBackupFolder($backupFolder);
|
||||||
->setBuilder($builder)->execute();
|
$bm = new BackupManager();
|
||||||
|
|
||||||
|
$bm->setBuilder($builder)->execute();
|
||||||
|
|
||||||
if ($bm->getShell()->getReturnValue() == 0) {
|
if ($bm->getShell()->getReturnValue() == 0) {
|
||||||
$this->line("<fg=green> |-> Data folder successfully backed up.</>");
|
$this->line("<fg=green> |-> Data folder successfully backed up.</>");
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,19 @@ class MysqlBackupCommand extends Command
|
||||||
$container = $this->option('container');
|
$container = $this->option('container');
|
||||||
$user = $this->option('user');
|
$user = $this->option('user');
|
||||||
$password = $this->option('password');
|
$password = $this->option('password');
|
||||||
|
|
||||||
|
if (!$container) {
|
||||||
|
$container = env('MYSQL_CONTAINER_NAME');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
$user = env('MYSQL_USER');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$password) {
|
||||||
|
$password = env('MYSQL_PASSWORD');
|
||||||
|
}
|
||||||
|
|
||||||
$bm = new BackupManager();
|
$bm = new BackupManager();
|
||||||
$this->line("<fg=blue>|-> Backing up mysql databases...</>");
|
$this->line("<fg=blue>|-> Backing up mysql databases...</>");
|
||||||
|
|
||||||
|
|
@ -46,17 +59,17 @@ class MysqlBackupCommand extends Command
|
||||||
$credentials->setUsername($user);
|
$credentials->setUsername($user);
|
||||||
$credentials->setPassword($password);
|
$credentials->setPassword($password);
|
||||||
|
|
||||||
$builder = new DatabaseBuilder();
|
|
||||||
$builder->setCredential($credentials);
|
|
||||||
$builder->setContainerName($container);
|
|
||||||
|
|
||||||
$backupFolder = $this->option('folder');
|
$backupFolder = $this->option('folder');
|
||||||
if (!$backupFolder) {
|
if (!$backupFolder) {
|
||||||
$backupFolder = env('BACKUP_FOLDER');
|
$backupFolder = env('BACKUP_FOLDER');
|
||||||
}
|
}
|
||||||
|
|
||||||
$bm->setBackupFolder($backupFolder)
|
$builder = new DatabaseBuilder();
|
||||||
->setBuilder($builder)->execute();
|
$builder->setCredential($credentials);
|
||||||
|
$builder->setContainerName($container)
|
||||||
|
->setBackupFolder($backupFolder);
|
||||||
|
|
||||||
|
$bm->setBuilder($builder)->execute();
|
||||||
|
|
||||||
if ($bm->getShell()->getReturnValue() == 0) {
|
if ($bm->getShell()->getReturnValue() == 0) {
|
||||||
$this->line("<fg=green> |-> Mysql databases successfully backed up.</>");
|
$this->line("<fg=green> |-> Mysql databases successfully backed up.</>");
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Commands;
|
||||||
|
|
||||||
|
use App\Utils\BackupManager;
|
||||||
|
use App\Utils\Builders\PackageBuilder;
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use LaravelZero\Framework\Commands\Command;
|
||||||
|
|
||||||
|
class PackCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The signature of the command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'backup:pack
|
||||||
|
{name : Package name.}
|
||||||
|
{--folder= : Backup folder.}
|
||||||
|
{--export= : Export folder for created package.}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The description of the command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Create backup package';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$backupFolder = $this->option('folder');
|
||||||
|
$exportFolder = $this->option('export');
|
||||||
|
$packageName = $this->argument('name');
|
||||||
|
|
||||||
|
if (!$backupFolder) {
|
||||||
|
$backupFolder = env('BACKUP_FOLDER');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$exportFolder) {
|
||||||
|
$exportFolder = env('EXPORT_FOLDER');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->line("<fg=blue>|-> {$packageName} is packing...</>");
|
||||||
|
|
||||||
|
$packageBuilder = new PackageBuilder();
|
||||||
|
$packageBuilder->setBackupFolder($backupFolder)
|
||||||
|
->setExportFolder($exportFolder)
|
||||||
|
->setPackageName($packageName);
|
||||||
|
|
||||||
|
$backupManager = new BackupManager();
|
||||||
|
$backupManager->setBuilder($packageBuilder)->execute();
|
||||||
|
|
||||||
|
if ($backupManager->getShell()->getReturnValue() == 0) {
|
||||||
|
$this->line("<fg=green> |-> Package created.</>");
|
||||||
|
} else {
|
||||||
|
$this->line("<fg=red> |-> Failed to create package.</>");
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Commands;
|
||||||
|
|
||||||
|
use App\Utils\BackupManager;
|
||||||
|
use App\Utils\Builders\DataBuilder;
|
||||||
|
use App\Utils\Builders\UploadBuilder;
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use LaravelZero\Framework\Commands\Command;
|
||||||
|
|
||||||
|
class UploadCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The signature of the command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'backup:upload
|
||||||
|
{name : Package name.}
|
||||||
|
{--export : Folder for created packages.}
|
||||||
|
{--target= : Target folder for Mega.nz}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The description of the command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Upload backup file to Mega.nz';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$exportFolder = $this->option('export');
|
||||||
|
$targetFolder = $this->option('target');
|
||||||
|
$name = $this->argument('name');
|
||||||
|
|
||||||
|
if (!$targetFolder) {
|
||||||
|
$targetFolder = env('TARGET_FOLDER');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$exportFolder) {
|
||||||
|
$exportFolder = env('EXPORT_FOLDER');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->line("<fg=blue>|-> {$name} is uploading...</>");
|
||||||
|
|
||||||
|
$uploadBuilder = new UploadBuilder();
|
||||||
|
$uploadBuilder->setExportFolder($exportFolder)
|
||||||
|
->setTargetFolder($targetFolder)
|
||||||
|
->setPackageName($name);
|
||||||
|
|
||||||
|
$backupManager = new BackupManager();
|
||||||
|
$backupManager->setBuilder($uploadBuilder)
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
if ($backupManager->getShell()->getReturnValue() == 0) {
|
||||||
|
$this->line("<fg=green> |-> Upload successful.</>");
|
||||||
|
} else {
|
||||||
|
$this->line("<fg=red> |-> Upload failed.</>");
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,41 +9,13 @@ use Throwable;
|
||||||
|
|
||||||
class BackupManager
|
class BackupManager
|
||||||
{
|
{
|
||||||
private $exportFolder;
|
|
||||||
private $backupFolder;
|
|
||||||
private $shell;
|
private $shell;
|
||||||
private $builder;
|
private $builder;
|
||||||
private $containerName;
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->shell = new Exec();
|
$this->shell = new Exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mixed $backupFolder
|
|
||||||
* @return BackupManager
|
|
||||||
* @throws Throwable
|
|
||||||
*/
|
|
||||||
public function setBackupFolder($backupFolder): BackupManager
|
|
||||||
{
|
|
||||||
throw_if(!file_exists($backupFolder), new BackupFolderNotFoundException('Backup folder not exist!'));
|
|
||||||
$this->backupFolder = $backupFolder;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mixed $exportFolder
|
|
||||||
* @return BackupManager
|
|
||||||
* @throws Throwable
|
|
||||||
*/
|
|
||||||
public function setExportFolder($exportFolder): BackupManager
|
|
||||||
{
|
|
||||||
throw_if(!file_exists($exportFolder), new ExportFolderNotFoundException('Export folder not exist!'));
|
|
||||||
$this->exportFolder = $exportFolder;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Exec
|
* @return Exec
|
||||||
*/
|
*/
|
||||||
|
|
@ -52,30 +24,6 @@ class BackupManager
|
||||||
return $this->shell;
|
return $this->shell;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getBackupFolder()
|
|
||||||
{
|
|
||||||
return $this->backupFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getExportFolder()
|
|
||||||
{
|
|
||||||
return $this->exportFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getContainerName()
|
|
||||||
{
|
|
||||||
return $this->containerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBuilder(Builder $builder): BackupManager
|
public function setBuilder(Builder $builder): BackupManager
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
|
|
@ -93,7 +41,7 @@ class BackupManager
|
||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
$builder = $this->getBuilder()->setBackupFolder($this->backupFolder)->builder();
|
$builder = $this->getBuilder()->builder();
|
||||||
return $this->shell->run($builder);
|
return $this->shell->run($builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,10 @@ use Throwable;
|
||||||
abstract class Builder
|
abstract class Builder
|
||||||
{
|
{
|
||||||
private $backupFolder;
|
private $backupFolder;
|
||||||
|
private $exportFolder;
|
||||||
|
private $targetFolder;
|
||||||
private $containerName;
|
private $containerName;
|
||||||
|
private $packageName;
|
||||||
private $clean;
|
private $clean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,6 +58,24 @@ abstract class Builder
|
||||||
return $this->backupFolder;
|
return $this->backupFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $exportFolder
|
||||||
|
* @return Builder
|
||||||
|
*/
|
||||||
|
public function setExportFolder(string $exportFolder): Builder
|
||||||
|
{
|
||||||
|
$this->exportFolder = $exportFolder;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getExportFolder(): string
|
||||||
|
{
|
||||||
|
return $this->exportFolder;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $containerName
|
* @param $containerName
|
||||||
* @return Builder
|
* @return Builder
|
||||||
|
|
@ -65,6 +86,24 @@ abstract class Builder
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $targetFolder
|
||||||
|
* @return Builder
|
||||||
|
*/
|
||||||
|
public function setTargetFolder(string $targetFolder): Builder
|
||||||
|
{
|
||||||
|
$this->targetFolder = $targetFolder;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTargetFolder(): string
|
||||||
|
{
|
||||||
|
return $this->targetFolder;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
@ -73,6 +112,24 @@ abstract class Builder
|
||||||
return $this->containerName;
|
return $this->containerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return Builder
|
||||||
|
*/
|
||||||
|
public function setPackageName(string $packageName): Builder
|
||||||
|
{
|
||||||
|
$this->packageName = $packageName;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPackageName(): string
|
||||||
|
{
|
||||||
|
return $this->packageName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $clean
|
* @param bool $clean
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Utils\Builders;
|
||||||
|
|
||||||
|
use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;
|
||||||
|
use App\Utils\Builder;
|
||||||
|
|
||||||
|
class PackageBuilder extends Builder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return CommandBuilder
|
||||||
|
*/
|
||||||
|
public function builder(): CommandBuilder
|
||||||
|
{
|
||||||
|
return new CommandBuilder("tar -zcf {$this->getExportFolder()}/{$this->getPackageName()}.tar.gz {$this->getBackupFolder()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Utils\Builders;
|
||||||
|
|
||||||
|
use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;
|
||||||
|
use App\Utils\Builder;
|
||||||
|
|
||||||
|
class UploadBuilder extends Builder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return CommandBuilder
|
||||||
|
*/
|
||||||
|
public function builder(): CommandBuilder
|
||||||
|
{
|
||||||
|
return new CommandBuilder("mega-put {$this->getExportFolder()}". DIRECTORY_SEPARATOR .
|
||||||
|
"{$this->getPackageName()} {$this->getTargetFolder()}/{$this->getPackageName()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue