From a5c656572d376fc01cd182b01a3c2420045fb535 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 23 Jun 2015 11:20:28 +0200 Subject: [PATCH 01/69] fix laravel 4 config loading issue --- src/Laravel4BackupManagerServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Laravel4BackupManagerServiceProvider.php b/src/Laravel4BackupManagerServiceProvider.php index 9de58f1..8f066f4 100644 --- a/src/Laravel4BackupManagerServiceProvider.php +++ b/src/Laravel4BackupManagerServiceProvider.php @@ -45,7 +45,7 @@ public function register() { */ private function registerFilesystemProvider() { $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { - $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager::storage'])); + $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); $provider->add(new Filesystems\Awss3Filesystem); $provider->add(new Filesystems\DropboxFilesystem); $provider->add(new Filesystems\FtpFilesystem); From ba045d5228eba57206e6164fcc9a3cc86c5d72f2 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 23 Jun 2015 11:25:11 +0200 Subject: [PATCH 02/69] update docs for laravel 4 / laravel 5 --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d61f2c6..7863510 100644 --- a/README.md +++ b/README.md @@ -56,23 +56,26 @@ composer require league/flysystem-rackspace composer require league/flysystem-sftp ``` -#### Laravel Configuration +#### Laravel 4 Configuration -To install into a Laravel project, first do the composer install then add **one of the following classes** to your config/app.php service providers list. +To install into a Laravel 4 project, first do the composer install then add the following class to your config/app.php service providers list. ```php BackupManager\Laravel\Laravel4BackupManagerServiceProvider::class, ``` -or +Copy the `vendor/backup-manager/laravel/config/backup-manager.php` file to `app/config/backup-manager.php` and configure it to suit your needs. + +#### Laravel 5 Configuration + +To install into a Laravel project, first do the composer install then add the following class to your config/app.php service providers list. ```php BackupManager\Laravel\Laravel5BackupManagerServiceProvider::class, ``` -Copy the `vendor/backup-manager/laravel/config/backup-manager.php` file to `app/config/backup-manager.php` and configure it to suit your needs. +Publish the storage configuration file. -If you are using Laravel 5 you can run this command to auto-publish the config file: ```php php artisan vendor:publish --provider="BackupManager\Laravel\Laravel5BackupManagerServiceProvider" ``` From 361ce832154a4d78211f466691268b4dc21b231f Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 23 Jun 2015 11:48:43 +0200 Subject: [PATCH 03/69] more laravel 4 / 5 separation (wip) --- src/{BaseCommand.php => AutoComplete.php} | 21 ++-------------- src/DbBackupCommand.php | 3 ++- src/DbListCommand.php | 21 +++++++++++++++- src/DbRestoreCommand.php | 24 ++++++++++++++++++- src/Laravel4Compatibility.php | 20 ++++++++++++++++ src/Laravel4DbBackupCommand.php | 11 +++++++++ ...ovider.php => Laravel4ServiceProvider.php} | 13 ++++++---- src/Laravel5Compatibility.php | 20 ++++++++++++++++ src/Laravel5DbBackupCommand.php | 11 +++++++++ ...ovider.php => Laravel5ServiceProvider.php} | 8 +++---- 10 files changed, 122 insertions(+), 30 deletions(-) rename src/{BaseCommand.php => AutoComplete.php} (61%) create mode 100644 src/Laravel4Compatibility.php create mode 100644 src/Laravel4DbBackupCommand.php rename src/{Laravel4BackupManagerServiceProvider.php => Laravel4ServiceProvider.php} (93%) create mode 100644 src/Laravel5Compatibility.php create mode 100644 src/Laravel5DbBackupCommand.php rename src/{Laravel5BackupManagerServiceProvider.php => Laravel5ServiceProvider.php} (95%) diff --git a/src/BaseCommand.php b/src/AutoComplete.php similarity index 61% rename from src/BaseCommand.php rename to src/AutoComplete.php index 5c26eff..64b8bb7 100644 --- a/src/BaseCommand.php +++ b/src/AutoComplete.php @@ -1,14 +1,10 @@ getHelperSet()->get('dialog'); return $helper->askAndValidate($this->output, "{$dialog}", $validation, false, $default, $list); } - - /** - * @param array $headers - * @param array $rows - * @internal param string $style - * @return void - */ - public function table(array $headers, array $rows, $style = 'default') { - $table = $this->getHelperSet()->get('table'); - $table->setHeaders($headers); - $table->setRows($rows); - $table->render($this->output); - } } diff --git a/src/DbBackupCommand.php b/src/DbBackupCommand.php index f6701ee..5b7ef59 100644 --- a/src/DbBackupCommand.php +++ b/src/DbBackupCommand.php @@ -9,7 +9,8 @@ * Class ManagerBackupCommand * @package BackupManager\Laravel */ -class DbBackupCommand extends BaseCommand { +class DbBackupCommand extends Command { + use AutoComplete; /** * The console command name. diff --git a/src/DbListCommand.php b/src/DbListCommand.php index a6a272e..4b22370 100644 --- a/src/DbListCommand.php +++ b/src/DbListCommand.php @@ -3,7 +3,12 @@ use Symfony\Component\Console\Input\InputOption; use BackupManager\Filesystems\FilesystemProvider; -class DbListCommand extends BaseCommand { +/** + * Class DbListCommand + * @package BackupManager\Laravel + */ +class DbListCommand extends Command { + use AutoComplete; /** * The console command name. @@ -39,6 +44,9 @@ class DbListCommand extends BaseCommand { private $missingArguments; + /** + * @param FilesystemProvider $filesystems + */ public function __construct(FilesystemProvider $filesystems) { parent::__construct(); $this->filesystems = $filesystems; @@ -111,6 +119,9 @@ private function promptForMissingArgumentValues() { } } + /** + * + */ private function askSource() { $providers = $this->filesystems->getAvailableProviders(); $formatted = implode(', ', $providers); @@ -119,6 +130,9 @@ private function askSource() { $this->input->setOption('source', $source); } + /** + * + */ private function askPath() { $root = $this->filesystems->getConfig($this->option('source'), 'root'); $path = $this->ask("From which path? {$root}"); @@ -166,6 +180,11 @@ protected function getOptions() { ]; } + /** + * @param $bytes + * @param int $precision + * @return string + */ private function formatBytes($bytes, $precision = 2) { $units = ['B', 'KB', 'MB', 'GB', 'TB']; $bytes = max($bytes, 0); diff --git a/src/DbRestoreCommand.php b/src/DbRestoreCommand.php index e2e6518..376da52 100644 --- a/src/DbRestoreCommand.php +++ b/src/DbRestoreCommand.php @@ -5,7 +5,12 @@ use BackupManager\Procedures\RestoreProcedure; use BackupManager\Filesystems\FilesystemProvider; -class DbRestoreCommand extends BaseCommand { +/** + * Class DbRestoreCommand + * @package BackupManager\Laravel + */ +class DbRestoreCommand extends Command { + use AutoComplete; /** * The console command name. @@ -129,6 +134,9 @@ private function promptForMissingArgumentValues() { } } + /** + * + */ private function askSource() { $providers = $this->filesystems->getAvailableProviders(); $formatted = implode(', ', $providers); @@ -137,6 +145,9 @@ private function askSource() { $this->input->setOption('source', $source); } + /** + * + */ private function askSourcePath() { // ask path $root = $this->filesystems->getConfig($this->option('source'), 'root'); @@ -175,6 +186,9 @@ private function askSourcePath() { $this->input->setOption('sourcePath', "{$path}/{$filename}"); } + /** + * + */ private function askDatabase() { $providers = $this->databases->getAvailableProviders(); $formatted = implode(', ', $providers); @@ -183,6 +197,9 @@ private function askDatabase() { $this->input->setOption('database', $database); } + /** + * + */ private function askCompression() { $types = ['null', 'gzip']; $formatted = implode(', ', $types); @@ -236,6 +253,11 @@ protected function getOptions() { ]; } + /** + * @param $bytes + * @param int $precision + * @return string + */ private function formatBytes($bytes, $precision = 2) { $units = ['B', 'KB', 'MB', 'GB', 'TB']; $bytes = max($bytes, 0); diff --git a/src/Laravel4Compatibility.php b/src/Laravel4Compatibility.php new file mode 100644 index 0000000..95fa44d --- /dev/null +++ b/src/Laravel4Compatibility.php @@ -0,0 +1,20 @@ +getHelperSet()->get('table'); + $table->setHeaders($headers); + $table->setRows($rows); + $table->render($this->output); + } +} diff --git a/src/Laravel4DbBackupCommand.php b/src/Laravel4DbBackupCommand.php new file mode 100644 index 0000000..c46f258 --- /dev/null +++ b/src/Laravel4DbBackupCommand.php @@ -0,0 +1,11 @@ +commands([ - \BackupManager\Laravel\DbBackupCommand::class, - \BackupManager\Laravel\DbRestoreCommand::class, - \BackupManager\Laravel\DbListCommand::class + \BackupManager\Laravel\Laravel4DbBackupCommand::class, +// \BackupManager\Laravel\DbRestoreCommand::class, +// \BackupManager\Laravel\DbListCommand::class ]); } @@ -121,6 +122,10 @@ public function provides() { ]; } + /** + * @param $connections + * @return Config + */ private function getDatabaseConfig($connections) { $mapped = array_map(function ($connection) { if ( ! in_array($connection['driver'], ['mysql', 'pgsql'])) { diff --git a/src/Laravel5Compatibility.php b/src/Laravel5Compatibility.php new file mode 100644 index 0000000..60d1ff2 --- /dev/null +++ b/src/Laravel5Compatibility.php @@ -0,0 +1,20 @@ +getHelperSet()->get('table'); + $table->setHeaders($headers); + $table->setRows($rows); + $table->render($this->output); + } +} diff --git a/src/Laravel5DbBackupCommand.php b/src/Laravel5DbBackupCommand.php new file mode 100644 index 0000000..6612559 --- /dev/null +++ b/src/Laravel5DbBackupCommand.php @@ -0,0 +1,11 @@ +commands([ - \BackupManager\Laravel\DbBackupCommand::class, - \BackupManager\Laravel\DbRestoreCommand::class, - \BackupManager\Laravel\DbListCommand::class, + \BackupManager\Laravel\Laravel5DbBackupCommand::class, +// \BackupManager\Laravel\DbRestoreCommand::class, +// \BackupManager\Laravel\DbListCommand::class, ]); } From 91af8011faed9adedc2ca5f7589069f2f46c3bf0 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 23 Jun 2015 11:53:20 +0200 Subject: [PATCH 04/69] master branch is 1.0-dev --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index d39c2ff..c1ca384 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,11 @@ "BackupManager\\Laravel\\": "src/" } }, + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, "license": "MIT", "minimum-stability": "dev" } From 9a9ab873b2730d60d945b688fdc4b6ef31e725de Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 23 Jun 2015 12:02:18 +0200 Subject: [PATCH 05/69] tweaks --- src/Laravel4DbBackupCommand.php | 2 +- src/Laravel5DbBackupCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Laravel4DbBackupCommand.php b/src/Laravel4DbBackupCommand.php index c46f258..b89b28b 100644 --- a/src/Laravel4DbBackupCommand.php +++ b/src/Laravel4DbBackupCommand.php @@ -6,6 +6,6 @@ * Class Laravel4DbBackupCommand * @package BackupManager\Laravel */ -class Laravel4DbBackupCommand extends DBBackupCommand { +class Laravel4DbBackupCommand extends DbBackupCommand { use Laravel4Compatibility; } diff --git a/src/Laravel5DbBackupCommand.php b/src/Laravel5DbBackupCommand.php index 6612559..2619b2b 100644 --- a/src/Laravel5DbBackupCommand.php +++ b/src/Laravel5DbBackupCommand.php @@ -6,6 +6,6 @@ * Class BaseCommand * @package BackupManager\Laravel */ -class Laravel5DbBackupCommand extends DBBackupCommand { +class Laravel5DbBackupCommand extends DbBackupCommand { use Laravel5Compatibility; } From d13cee1095ee37380d87722a74693752e67bda1d Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 23 Jun 2015 12:04:59 +0200 Subject: [PATCH 06/69] update --- src/DbBackupCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DbBackupCommand.php b/src/DbBackupCommand.php index 5b7ef59..df10bdd 100644 --- a/src/DbBackupCommand.php +++ b/src/DbBackupCommand.php @@ -1,5 +1,6 @@ Date: Tue, 23 Jun 2015 12:10:27 +0200 Subject: [PATCH 07/69] add near-final separation between l4 and l5 --- src/DbListCommand.php | 1 + src/DbRestoreCommand.php | 1 + src/Laravel4DbListCommand.php | 11 +++++++++++ src/Laravel4DbRestoreCommand.php | 11 +++++++++++ src/Laravel4ServiceProvider.php | 4 ++-- src/Laravel5DbBackupCommand.php | 2 +- src/Laravel5DbListCommand.php | 11 +++++++++++ src/Laravel5DbRestoreCommand.php | 11 +++++++++++ src/Laravel5ServiceProvider.php | 4 ++-- 9 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 src/Laravel4DbListCommand.php create mode 100644 src/Laravel4DbRestoreCommand.php create mode 100644 src/Laravel5DbListCommand.php create mode 100644 src/Laravel5DbRestoreCommand.php diff --git a/src/DbListCommand.php b/src/DbListCommand.php index 4b22370..9e207d8 100644 --- a/src/DbListCommand.php +++ b/src/DbListCommand.php @@ -1,5 +1,6 @@ commands([ \BackupManager\Laravel\Laravel4DbBackupCommand::class, -// \BackupManager\Laravel\DbRestoreCommand::class, -// \BackupManager\Laravel\DbListCommand::class + \BackupManager\Laravel\Laravel4DbRestoreCommand::class, + \BackupManager\Laravel\Laravel4DbListCommand::class ]); } diff --git a/src/Laravel5DbBackupCommand.php b/src/Laravel5DbBackupCommand.php index 2619b2b..1d35f92 100644 --- a/src/Laravel5DbBackupCommand.php +++ b/src/Laravel5DbBackupCommand.php @@ -3,7 +3,7 @@ use Illuminate\Console\Command; /** - * Class BaseCommand + * Class Laravel5DbBackupCommand * @package BackupManager\Laravel */ class Laravel5DbBackupCommand extends DbBackupCommand { diff --git a/src/Laravel5DbListCommand.php b/src/Laravel5DbListCommand.php new file mode 100644 index 0000000..25eaa1d --- /dev/null +++ b/src/Laravel5DbListCommand.php @@ -0,0 +1,11 @@ +commands([ \BackupManager\Laravel\Laravel5DbBackupCommand::class, -// \BackupManager\Laravel\DbRestoreCommand::class, -// \BackupManager\Laravel\DbListCommand::class, + \BackupManager\Laravel\Laravel5DbRestoreCommand::class, + \BackupManager\Laravel\Laravel5DbListCommand::class, ]); } From b314c562285cafd1820d758f8575997eb2b0a6ed Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 23 Jun 2015 12:17:31 +0200 Subject: [PATCH 08/69] complete laravel 4 and 5 compatibility --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7863510..aafe0ed 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ composer require league/flysystem-sftp To install into a Laravel 4 project, first do the composer install then add the following class to your config/app.php service providers list. ```php -BackupManager\Laravel\Laravel4BackupManagerServiceProvider::class, +BackupManager\Laravel\Laravel4ServiceProvider::class, ``` Copy the `vendor/backup-manager/laravel/config/backup-manager.php` file to `app/config/backup-manager.php` and configure it to suit your needs. @@ -71,7 +71,7 @@ Copy the `vendor/backup-manager/laravel/config/backup-manager.php` file to `app/ To install into a Laravel project, first do the composer install then add the following class to your config/app.php service providers list. ```php -BackupManager\Laravel\Laravel5BackupManagerServiceProvider::class, +BackupManager\Laravel\Laravel5ServiceProvider::class, ``` Publish the storage configuration file. From 1383b50aaec8436d81b53f00ecafd6eb48cadb77 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 23 Jun 2015 12:18:28 +0200 Subject: [PATCH 09/69] tweak minimum stability --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c1ca384..498f942 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,5 @@ "dev-master": "1.0-dev" } }, - "license": "MIT", - "minimum-stability": "dev" + "license": "MIT" } From 26d32dfa592848d8e51e4cec0a177b16f612c256 Mon Sep 17 00:00:00 2001 From: hansvn Date: Mon, 13 Jul 2015 14:02:06 +0200 Subject: [PATCH 10/69] Update Autocomplete to fix namespace bug Update The file with backslash before InvalidArgumentException so php can find this class. The current namespace doesn't hold this class --- src/AutoComplete.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AutoComplete.php b/src/AutoComplete.php index 64b8bb7..e9d8add 100644 --- a/src/AutoComplete.php +++ b/src/AutoComplete.php @@ -17,7 +17,7 @@ trait AutoComplete { public function autocomplete($dialog, array $list, $default = null) { $validation = function ($item) use ($list) { if ( ! in_array($item, array_values($list))) { - throw new InvalidArgumentException("{$item} does not exist."); + throw new \InvalidArgumentException("{$item} does not exist."); } return $item; }; From beaf5dcab9ac76d4385cd405ec78b894c6a01a84 Mon Sep 17 00:00:00 2001 From: Joe Aliperti Date: Fri, 17 Jul 2015 12:29:16 -0400 Subject: [PATCH 11/69] fixed vendor:publish typo that prevented the configuration file from being copied --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aafe0ed..e80d9ea 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ BackupManager\Laravel\Laravel5ServiceProvider::class, Publish the storage configuration file. ```php -php artisan vendor:publish --provider="BackupManager\Laravel\Laravel5BackupManagerServiceProvider" +php artisan vendor:publish --provider="BackupManager\Laravel\Laravel5ServiceProvider" ``` The Backup Manager will make use of Laravel's database configuration. But, it won't know about any connections that might be tied to other environments, so it can be best to just list multiple connections in the `config/database.php` file. From a23bdf2fe6ced57a0008cfeac8f368fc7a9faf6d Mon Sep 17 00:00:00 2001 From: Louis Laszlo Date: Fri, 7 Aug 2015 16:42:22 +0200 Subject: [PATCH 12/69] Removing the process timeout --- src/Laravel5ServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Laravel5ServiceProvider.php b/src/Laravel5ServiceProvider.php index 8587ec9..21a9950 100644 --- a/src/Laravel5ServiceProvider.php +++ b/src/Laravel5ServiceProvider.php @@ -94,7 +94,7 @@ private function registerCompressorProvider() { */ private function registerShellProcessor() { $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { - return new ShellProcessor(new Process('')); + return new ShellProcessor(new Process('', null, null, null, null)); }); } From 912384ba729896894d95a62cd7ba7265f9d4448e Mon Sep 17 00:00:00 2001 From: Louis Laszlo Date: Fri, 7 Aug 2015 16:42:51 +0200 Subject: [PATCH 13/69] Update Laravel4ServiceProvider.php --- src/Laravel4ServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Laravel4ServiceProvider.php b/src/Laravel4ServiceProvider.php index 39f8c9d..b35b2b4 100644 --- a/src/Laravel4ServiceProvider.php +++ b/src/Laravel4ServiceProvider.php @@ -92,7 +92,7 @@ private function registerCompressorProvider() { */ private function registerShellProcessor() { $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { - return new ShellProcessor(new Process('')); + return new ShellProcessor(new Process('', null, null, null, null)); }); } From 2917347ffdb991f545c85e91efaef4139ef0284a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20=C3=87al=C4=B1k?= Date: Mon, 7 Sep 2015 14:55:02 +0300 Subject: [PATCH 14/69] Added Google Cloud Storage support. --- README.md | 2 +- config/backup-manager.php | 7 +++++++ src/Laravel4ServiceProvider.php | 1 + src/Laravel5ServiceProvider.php | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e80d9ea..31c0b0e 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ composer require backup-manager/laravel Then, you'll need to select the appropriate packages for the adapters that you want to use. ```shell -# to support s3 +# to support s3 or google cs composer require league/flysystem-aws-s3-v2 # to support dropbox diff --git a/config/backup-manager.php b/config/backup-manager.php index f5a1167..f2dd3dc 100644 --- a/config/backup-manager.php +++ b/config/backup-manager.php @@ -13,6 +13,13 @@ 'bucket' => '', 'root' => '', ], + 'gcs' => [ + 'type' => 'Gcs', + 'key' => '', + 'secret' => '', + 'bucket' => '', + 'root' => '', + ], 'rackspace' => [ 'type' => 'Rackspace', 'username' => '', diff --git a/src/Laravel4ServiceProvider.php b/src/Laravel4ServiceProvider.php index b35b2b4..a030cdf 100644 --- a/src/Laravel4ServiceProvider.php +++ b/src/Laravel4ServiceProvider.php @@ -48,6 +48,7 @@ private function registerFilesystemProvider() { $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); $provider->add(new Filesystems\Awss3Filesystem); + $provider->add(new Filesystems\GcsFilesystem); $provider->add(new Filesystems\DropboxFilesystem); $provider->add(new Filesystems\FtpFilesystem); $provider->add(new Filesystems\LocalFilesystem); diff --git a/src/Laravel5ServiceProvider.php b/src/Laravel5ServiceProvider.php index 21a9950..143da44 100644 --- a/src/Laravel5ServiceProvider.php +++ b/src/Laravel5ServiceProvider.php @@ -50,6 +50,7 @@ private function registerFilesystemProvider() { $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); $provider->add(new Filesystems\Awss3Filesystem); + $provider->add(new Filesystems\GcsFilesystem); $provider->add(new Filesystems\DropboxFilesystem); $provider->add(new Filesystems\FtpFilesystem); $provider->add(new Filesystems\LocalFilesystem); From 9240d27dbe68a2570bdf5fc893b0f5564b986187 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 29 Oct 2015 05:30:47 +0200 Subject: [PATCH 15/69] Update Readme added example command of scheduled backups --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e80d9ea..63561fe 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,12 @@ There are three commands available `db:backup`, `db:restore` and `db:list`. All will prompt you with simple questions to successfully execute the command. +**Example Command for 24hour scheduled cronjob** + +`php artisan db:backup --database=mysql --destination=dropbox --destinationPath=``date +\%Y/%d-%m-%Y`` --compression=gzip` + +This command will backup your database to dropbox using mysql and gzip compresion in path /backups/YEAR/DATE.gz (ex: /backups/2015/29-10-2015.gz) + ### Contribution Guidelines We recommend using the vagrant configuration supplied with this package for development and contribution. Simply install VirtualBox, Vagrant, and Ansible then run `vagrant up` in the root folder. A virtualmachine specifically designed for development of the package will be built and launched for you. From f750f7177fea473d5712b7a7fd884f8cc1047cf2 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 29 Oct 2015 05:33:54 +0200 Subject: [PATCH 16/69] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 63561fe..9564b3e 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,9 @@ All will prompt you with simple questions to successfully execute the command. **Example Command for 24hour scheduled cronjob** -`php artisan db:backup --database=mysql --destination=dropbox --destinationPath=``date +\%Y/%d-%m-%Y`` --compression=gzip` +``` + php artisan db:backup --database=mysql --destination=dropbox --destinationPath=``date +\%Y/%d-%m-%Y`` --compression=gzip +``` This command will backup your database to dropbox using mysql and gzip compresion in path /backups/YEAR/DATE.gz (ex: /backups/2015/29-10-2015.gz) From c6beb92537de6fbabade75f64115518688e486f4 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 29 Oct 2015 05:36:01 +0200 Subject: [PATCH 17/69] Update README.md fix indentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9564b3e..6f0a84d 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ All will prompt you with simple questions to successfully execute the command. **Example Command for 24hour scheduled cronjob** ``` - php artisan db:backup --database=mysql --destination=dropbox --destinationPath=``date +\%Y/%d-%m-%Y`` --compression=gzip +php artisan db:backup --database=mysql --destination=dropbox --destinationPath=`date +\%Y/%d-%m-%Y` --compression=gzip ``` This command will backup your database to dropbox using mysql and gzip compresion in path /backups/YEAR/DATE.gz (ex: /backups/2015/29-10-2015.gz) From 275faa38524456634d0414dd1340d88c4dd81f98 Mon Sep 17 00:00:00 2001 From: Oskar Danielsson Date: Thu, 12 Nov 2015 13:12:12 +0100 Subject: [PATCH 18/69] Swapped '/' for PHP_EOL Swapped weird-looking '/' for compiler-generated PHP_EOL (The message looks stupid in Windows command prompt) --- src/DbBackupCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DbBackupCommand.php b/src/DbBackupCommand.php index df10bdd..ce5708b 100644 --- a/src/DbBackupCommand.php +++ b/src/DbBackupCommand.php @@ -99,7 +99,7 @@ public function fire() { $this->option('database'), $this->option('compression'), $this->option('destination'), - $root .'/'. $this->option('destinationPath') + $root .DIRECTORY_SEPARATOR. $this->option('destinationPath') )); } From ae89122ac06bd3d897bb7761ff1b476ca74d600e Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 17 Nov 2015 00:13:29 +0100 Subject: [PATCH 19/69] separate laravel 5.0 and 5.1 backward compatibility --- README.md | 4 +- src/Laravel50Compatibility.php | 20 +++ src/Laravel50DbBackupCommand.php | 11 ++ src/Laravel50DbListCommand.php | 11 ++ src/Laravel50DbRestoreCommand.php | 11 ++ src/Laravel50ServiceProvider.php | 154 ++++++++++++++++++ ...ibility.php => Laravel51Compatibility.php} | 2 +- src/Laravel5DbBackupCommand.php | 2 +- src/Laravel5DbListCommand.php | 2 +- src/Laravel5DbRestoreCommand.php | 2 +- 10 files changed, 213 insertions(+), 6 deletions(-) create mode 100644 src/Laravel50Compatibility.php create mode 100644 src/Laravel50DbBackupCommand.php create mode 100644 src/Laravel50DbListCommand.php create mode 100644 src/Laravel50DbRestoreCommand.php create mode 100644 src/Laravel50ServiceProvider.php rename src/{Laravel5Compatibility.php => Laravel51Compatibility.php} (93%) diff --git a/README.md b/README.md index aafe0ed..a1e42d7 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ This package pulls in the framework agnostic [Backup Manager](https://github.com/backup-manager/backup-manager) and provides seamless integration with **Laravel**. -Mitchell has put together a [video tour](https://www.youtube.com/watch?v=vWXy0R8OavM) of Laravel integration, to give you an idea what is possible with this package. +[Watch a video tour](https://www.youtube.com/watch?v=vWXy0R8OavM) to get an idea what is possible with this package. -> Note: This package is for Laravel integration only. For information about the base package please see [the base package repository](https://github.com/backup-manager/backup-manager). +> Note: This package is for Laravel integration only. For information about the framework-agnostic core package (or the Symfony driver) please see [the base package repository](https://github.com/backup-manager/backup-manager). ### Table of Contents diff --git a/src/Laravel50Compatibility.php b/src/Laravel50Compatibility.php new file mode 100644 index 0000000..abe02b2 --- /dev/null +++ b/src/Laravel50Compatibility.php @@ -0,0 +1,20 @@ +getHelperSet()->get('table'); + $table->setHeaders($headers); + $table->setRows($rows); + $table->render($this->output); + } +} diff --git a/src/Laravel50DbBackupCommand.php b/src/Laravel50DbBackupCommand.php new file mode 100644 index 0000000..6c5ed07 --- /dev/null +++ b/src/Laravel50DbBackupCommand.php @@ -0,0 +1,11 @@ +publishes([$configPath => config_path('backup-manager.php')], 'config'); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() { + $configPath = __DIR__ . '/../config/backup-manager.php'; + $this->mergeConfigFrom($configPath, 'backup-manager'); + $this->registerFilesystemProvider(); + $this->registerDatabaseProvider(); + $this->registerCompressorProvider(); + $this->registerShellProcessor(); + $this->registerArtisanCommands(); + } + + /** + * Register the filesystem provider. + * + * @return void + */ + private function registerFilesystemProvider() { + $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { + $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); + $provider->add(new Filesystems\Awss3Filesystem); + $provider->add(new Filesystems\DropboxFilesystem); + $provider->add(new Filesystems\FtpFilesystem); + $provider->add(new Filesystems\LocalFilesystem); + $provider->add(new Filesystems\RackspaceFilesystem); + $provider->add(new Filesystems\SftpFilesystem); + return $provider; + }); + } + + /** + * Register the database provider. + * + * @return void + */ + private function registerDatabaseProvider() { + $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) { + $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections'])); + $provider->add(new Databases\MysqlDatabase); + $provider->add(new Databases\PostgresqlDatabase); + return $provider; + }); + } + + /** + * Register the compressor provider. + * + * @return void + */ + private function registerCompressorProvider() { + $this->app->bind(\BackupManager\Compressors\CompressorProvider::class, function () { + $provider = new Compressors\CompressorProvider; + $provider->add(new Compressors\GzipCompressor); + $provider->add(new Compressors\NullCompressor); + return $provider; + }); + } + + /** + * Register the filesystem provider. + * + * @return void + */ + private function registerShellProcessor() { + $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { + return new ShellProcessor(new Process('')); + }); + } + + /** + * Register the artisan commands. + * + * @return void + */ + private function registerArtisanCommands() { + $this->commands([ + \BackupManager\Laravel\Laravel50DbBackupCommand::class, + \BackupManager\Laravel\Laravel50DbRestoreCommand::class, + \BackupManager\Laravel\Laravel50DbListCommand::class, + ]); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() { + return [ + \BackupManager\Filesystems\FilesystemProvider::class, + \BackupManager\Databases\DatabaseProvider::class, + \BackupManager\ShellProcessing\ShellProcessor::class, + ]; + } + + private function getDatabaseConfig($connections) { + $mapped = array_map(function ($connection) { + if ( ! in_array($connection['driver'], ['mysql', 'pgsql'])) { + return; + } + + if (isset($connection['port'])) { + $port = $connection['port']; + } else { + if ($connection['driver'] == 'mysql') { + $port = '3306'; + } elseif ($connection['driver'] == 'pgsql') { + $port = '5432'; + } + } + + return [ + 'type' => $connection['driver'], + 'host' => $connection['host'], + 'port' => $port, + 'user' => $connection['username'], + 'pass' => $connection['password'], + 'database' => $connection['database'], + ]; + }, $connections); + return new Config($mapped); + } +} diff --git a/src/Laravel5Compatibility.php b/src/Laravel51Compatibility.php similarity index 93% rename from src/Laravel5Compatibility.php rename to src/Laravel51Compatibility.php index 60d1ff2..551f34f 100644 --- a/src/Laravel5Compatibility.php +++ b/src/Laravel51Compatibility.php @@ -4,7 +4,7 @@ * Class Laravel5Compatibility * @package BackupManager\Laravel */ -trait Laravel5Compatibility { +trait Laravel51Compatibility { /** * @param array $headers * @param array $rows diff --git a/src/Laravel5DbBackupCommand.php b/src/Laravel5DbBackupCommand.php index 1d35f92..eb73cb6 100644 --- a/src/Laravel5DbBackupCommand.php +++ b/src/Laravel5DbBackupCommand.php @@ -7,5 +7,5 @@ * @package BackupManager\Laravel */ class Laravel5DbBackupCommand extends DbBackupCommand { - use Laravel5Compatibility; + use Laravel51Compatibility; } diff --git a/src/Laravel5DbListCommand.php b/src/Laravel5DbListCommand.php index 25eaa1d..bc738af 100644 --- a/src/Laravel5DbListCommand.php +++ b/src/Laravel5DbListCommand.php @@ -7,5 +7,5 @@ * @package BackupManager\Laravel */ class Laravel5DbListCommand extends DbListCommand { - use Laravel5Compatibility; + use Laravel51Compatibility; } diff --git a/src/Laravel5DbRestoreCommand.php b/src/Laravel5DbRestoreCommand.php index 088437e..8bea156 100644 --- a/src/Laravel5DbRestoreCommand.php +++ b/src/Laravel5DbRestoreCommand.php @@ -7,5 +7,5 @@ * @package BackupManager\Laravel */ class Laravel5DbRestoreCommand extends DbRestoreCommand { - use Laravel5Compatibility; + use Laravel51Compatibility; } From cfe721af5722070c214c20b6f96d8de10f18d4b8 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 17 Nov 2015 00:19:59 +0100 Subject: [PATCH 20/69] fix laravel 5.0 support --- src/Laravel50DbListCommand.php | 2 +- src/Laravel50DbRestoreCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Laravel50DbListCommand.php b/src/Laravel50DbListCommand.php index 76d790a..15a48a8 100644 --- a/src/Laravel50DbListCommand.php +++ b/src/Laravel50DbListCommand.php @@ -7,5 +7,5 @@ * @package BackupManager\Laravel */ class Laravel50DbListCommand extends DbListCommand { - use Laravel51Compatibility; + use Laravel50Compatibility; } diff --git a/src/Laravel50DbRestoreCommand.php b/src/Laravel50DbRestoreCommand.php index 5a9b4f2..9844b43 100644 --- a/src/Laravel50DbRestoreCommand.php +++ b/src/Laravel50DbRestoreCommand.php @@ -7,5 +7,5 @@ * @package BackupManager\Laravel */ class Laravel50DbRestoreCommand extends DbRestoreCommand { - use Laravel51Compatibility; + use Laravel50Compatibility; } From 8036df61495c5bde3ec1ccbf94af0a8fbbe2b64b Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 17 Nov 2015 00:21:08 +0100 Subject: [PATCH 21/69] update documentation with laravel 5.0 support --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cddbbc8..89b5fd3 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,13 @@ Copy the `vendor/backup-manager/laravel/config/backup-manager.php` file to `app/ #### Laravel 5 Configuration -To install into a Laravel project, first do the composer install then add the following class to your config/app.php service providers list. +To install into a Laravel project, first do the composer install then add *ONE *of the following classes to your config/app.php service providers list. ```php +// FOR LARAVEL 5.0 ONLY +BackupManager\Laravel\Laravel50ServiceProvider::class, + +// FOR LARAVEL 5.1 AND ABOVE BackupManager\Laravel\Laravel5ServiceProvider::class, ``` From 6309952a138dd50305858833b8390e5c6fc25eaf Mon Sep 17 00:00:00 2001 From: Sam Jordan Date: Wed, 2 Dec 2015 11:00:53 +0000 Subject: [PATCH 22/69] Fixed s3 lib requirement in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89b5fd3..d49f715 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Then, you'll need to select the appropriate packages for the adapters that you w ```shell # to support s3 or google cs -composer require league/flysystem-aws-s3-v2 +composer require league/flysystem-aws-s3-v3 # to support dropbox composer require league/flysystem-dropbox From 453bf5f173d3bedd39890600b37a108778b67d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Youn=C3=A8s?= Date: Fri, 4 Dec 2015 23:00:44 +0100 Subject: [PATCH 23/69] php7 support composer will now install under php7 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 498f942..65bd23e 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ ], "require": { "backup-manager/backup-manager": "^1.0", - "php": "^5.5.0", + "php": ">=5.5.0", "symfony/process": "^2.0", "illuminate/support": "^4.0||^5.0", "illuminate/container": "^4.0||^5.0", From 642bfa52b44b6d012a425593dc8b714d8c853033 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Mon, 7 Dec 2015 10:53:56 +0100 Subject: [PATCH 24/69] add scheduling documentation --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 89b5fd3..0afc9c4 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This package pulls in the framework agnostic [Backup Manager](https://github.com - [Stability Notice](#stability-notice) - [Requirements](#requirements) - [Installation](#installation) -- [Usage](#usage) +- [Scheduling Backups](#scheduling) - [Contribution Guidelines](#contribution-guidelines) - [Maintainers](#maintainers) - [License](#license) @@ -118,6 +118,24 @@ php artisan db:backup --database=mysql --destination=dropbox --destinationPath=` This command will backup your database to dropbox using mysql and gzip compresion in path /backups/YEAR/DATE.gz (ex: /backups/2015/29-10-2015.gz) +### Scheduling Backups + +It's possible to schedule backups using Laravel's scheduler. + +```PHP +/** + * Define the application's command schedule. + * + * @param \Illuminate\Console\Scheduling\Schedule $schedule + * @return void + */ +protected function schedule(Schedule $schedule) { + $date = Carbon::now()->toW3cString(); + $environment = env('APP_ENV'); + $schedule->command("db:backup --database=mysql --destination=s3 --destinationPath=/{$environment}/projectname_{$environment}_{$date} --compression=gzip")->twiceDaily(13,21); +} +``` + ### Contribution Guidelines We recommend using the vagrant configuration supplied with this package for development and contribution. Simply install VirtualBox, Vagrant, and Ansible then run `vagrant up` in the root folder. A virtualmachine specifically designed for development of the package will be built and launched for you. From cfa3842ade37322d62bbaf39ee06c134817ad7bb Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Mon, 7 Dec 2015 10:54:41 +0100 Subject: [PATCH 25/69] fix anchor --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bfd4188..add1c68 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This package pulls in the framework agnostic [Backup Manager](https://github.com - [Stability Notice](#stability-notice) - [Requirements](#requirements) - [Installation](#installation) -- [Scheduling Backups](#scheduling) +- [Scheduling Backups](#scheduling-backups) - [Contribution Guidelines](#contribution-guidelines) - [Maintainers](#maintainers) - [License](#license) From a063dd546a98ee4d96748d77e22d3de1b3ba1fea Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Mon, 7 Dec 2015 10:55:51 +0100 Subject: [PATCH 26/69] update copy --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index add1c68..5ab5f79 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,9 @@ It's possible to schedule backups using Laravel's scheduler. protected function schedule(Schedule $schedule) { $date = Carbon::now()->toW3cString(); $environment = env('APP_ENV'); - $schedule->command("db:backup --database=mysql --destination=s3 --destinationPath=/{$environment}/projectname_{$environment}_{$date} --compression=gzip")->twiceDaily(13,21); + $schedule->command( + "db:backup --database=mysql --destination=s3 --destinationPath=/{$environment}/projectname_{$environment}_{$date} --compression=gzip" + )->twiceDaily(13,21); } ``` From dc9be835deea5d65ce9bf140afed2b664d8def7f Mon Sep 17 00:00:00 2001 From: Doug Sisk Date: Wed, 23 Dec 2015 16:39:57 -0700 Subject: [PATCH 27/69] Lumen Service Providers --- src/Lumen50ServiceProvider.php | 144 ++++++++++++++++++++++++++++++++ src/LumenServiceProvider.php | 145 +++++++++++++++++++++++++++++++++ 2 files changed, 289 insertions(+) create mode 100644 src/Lumen50ServiceProvider.php create mode 100644 src/LumenServiceProvider.php diff --git a/src/Lumen50ServiceProvider.php b/src/Lumen50ServiceProvider.php new file mode 100644 index 0000000..a808e58 --- /dev/null +++ b/src/Lumen50ServiceProvider.php @@ -0,0 +1,144 @@ +mergeConfigFrom($configPath, 'backup-manager'); + $this->registerFilesystemProvider(); + $this->registerDatabaseProvider(); + $this->registerCompressorProvider(); + $this->registerShellProcessor(); + $this->registerArtisanCommands(); + } + + /** + * Register the filesystem provider. + * + * @return void + */ + private function registerFilesystemProvider() { + $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { + $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); + $provider->add(new Filesystems\Awss3Filesystem); + $provider->add(new Filesystems\DropboxFilesystem); + $provider->add(new Filesystems\FtpFilesystem); + $provider->add(new Filesystems\LocalFilesystem); + $provider->add(new Filesystems\RackspaceFilesystem); + $provider->add(new Filesystems\SftpFilesystem); + return $provider; + }); + } + + /** + * Register the database provider. + * + * @return void + */ + private function registerDatabaseProvider() { + $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) { + $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections'])); + $provider->add(new Databases\MysqlDatabase); + $provider->add(new Databases\PostgresqlDatabase); + return $provider; + }); + } + + /** + * Register the compressor provider. + * + * @return void + */ + private function registerCompressorProvider() { + $this->app->bind(\BackupManager\Compressors\CompressorProvider::class, function () { + $provider = new Compressors\CompressorProvider; + $provider->add(new Compressors\GzipCompressor); + $provider->add(new Compressors\NullCompressor); + return $provider; + }); + } + + /** + * Register the filesystem provider. + * + * @return void + */ + private function registerShellProcessor() { + $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { + return new ShellProcessor(new Process('')); + }); + } + + /** + * Register the artisan commands. + * + * @return void + */ + private function registerArtisanCommands() { + $this->commands([ + \BackupManager\Laravel\Laravel50DbBackupCommand::class, + \BackupManager\Laravel\Laravel50DbRestoreCommand::class, + \BackupManager\Laravel\Laravel50DbListCommand::class, + ]); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() { + return [ + \BackupManager\Filesystems\FilesystemProvider::class, + \BackupManager\Databases\DatabaseProvider::class, + \BackupManager\ShellProcessing\ShellProcessor::class, + ]; + } + + private function getDatabaseConfig($connections) { + $mapped = array_map(function ($connection) { + if ( ! in_array($connection['driver'], ['mysql', 'pgsql'])) { + return; + } + + if (isset($connection['port'])) { + $port = $connection['port']; + } else { + if ($connection['driver'] == 'mysql') { + $port = '3306'; + } elseif ($connection['driver'] == 'pgsql') { + $port = '5432'; + } + } + + return [ + 'type' => $connection['driver'], + 'host' => $connection['host'], + 'port' => $port, + 'user' => $connection['username'], + 'pass' => $connection['password'], + 'database' => $connection['database'], + ]; + }, $connections); + return new Config($mapped); + } +} diff --git a/src/LumenServiceProvider.php b/src/LumenServiceProvider.php new file mode 100644 index 0000000..64cec63 --- /dev/null +++ b/src/LumenServiceProvider.php @@ -0,0 +1,145 @@ +mergeConfigFrom($configPath, 'backup-manager'); + $this->registerFilesystemProvider(); + $this->registerDatabaseProvider(); + $this->registerCompressorProvider(); + $this->registerShellProcessor(); + $this->registerArtisanCommands(); + } + + /** + * Register the filesystem provider. + * + * @return void + */ + private function registerFilesystemProvider() { + $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { + $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); + $provider->add(new Filesystems\Awss3Filesystem); + $provider->add(new Filesystems\GcsFilesystem); + $provider->add(new Filesystems\DropboxFilesystem); + $provider->add(new Filesystems\FtpFilesystem); + $provider->add(new Filesystems\LocalFilesystem); + $provider->add(new Filesystems\RackspaceFilesystem); + $provider->add(new Filesystems\SftpFilesystem); + return $provider; + }); + } + + /** + * Register the database provider. + * + * @return void + */ + private function registerDatabaseProvider() { + $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) { + $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections'])); + $provider->add(new Databases\MysqlDatabase); + $provider->add(new Databases\PostgresqlDatabase); + return $provider; + }); + } + + /** + * Register the compressor provider. + * + * @return void + */ + private function registerCompressorProvider() { + $this->app->bind(\BackupManager\Compressors\CompressorProvider::class, function () { + $provider = new Compressors\CompressorProvider; + $provider->add(new Compressors\GzipCompressor); + $provider->add(new Compressors\NullCompressor); + return $provider; + }); + } + + /** + * Register the filesystem provider. + * + * @return void + */ + private function registerShellProcessor() { + $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { + return new ShellProcessor(new Process('', null, null, null, null)); + }); + } + + /** + * Register the artisan commands. + * + * @return void + */ + private function registerArtisanCommands() { + $this->commands([ + \BackupManager\Laravel\Laravel5DbBackupCommand::class, + \BackupManager\Laravel\Laravel5DbRestoreCommand::class, + \BackupManager\Laravel\Laravel5DbListCommand::class, + ]); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() { + return [ + \BackupManager\Filesystems\FilesystemProvider::class, + \BackupManager\Databases\DatabaseProvider::class, + \BackupManager\ShellProcessing\ShellProcessor::class, + ]; + } + + private function getDatabaseConfig($connections) { + $mapped = array_map(function ($connection) { + if ( ! in_array($connection['driver'], ['mysql', 'pgsql'])) { + return; + } + + if (isset($connection['port'])) { + $port = $connection['port']; + } else { + if ($connection['driver'] == 'mysql') { + $port = '3306'; + } elseif ($connection['driver'] == 'pgsql') { + $port = '5432'; + } + } + + return [ + 'type' => $connection['driver'], + 'host' => $connection['host'], + 'port' => $port, + 'user' => $connection['username'], + 'pass' => $connection['password'], + 'database' => $connection['database'], + ]; + }, $connections); + return new Config($mapped); + } +} From 25fb03cfb6768a165be7806745b80a1b512296f0 Mon Sep 17 00:00:00 2001 From: Doug Sisk Date: Thu, 24 Dec 2015 13:25:20 -0700 Subject: [PATCH 28/69] Lumen configuration in README --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 5ab5f79..eb4e740 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,22 @@ php artisan vendor:publish --provider="BackupManager\Laravel\Laravel5ServiceProv The Backup Manager will make use of Laravel's database configuration. But, it won't know about any connections that might be tied to other environments, so it can be best to just list multiple connections in the `config/database.php` file. +#### Lumen Configuration + +To install into a Lumen project, first do the composer install then add *ONE* of the following service providers to your `boostrap/app.php`. + +```php +// FOR LUMEN 5.0 ONLY +$app->configure('backup-manager'); +$app->register(BackupManager\Laravel\Lumen50ServiceProvider::class); + +// FOR LUMEN 5.1 AND ABOVE +$app->configure('backup-manager'); +$app->register(BackupManager\Laravel\LumenServiceProvider::class); +``` + +Copy the `vendor/backup-manager/laravel/config/backup-manager.php` file to `config/backup-manager.php` and configure it to suit your needs. + **IoC Resolution** `BackupManager\Manager` can be automatically resolved through constructor injection thanks to Laravel's IoC container. From ed2522b5695ed2956791c8b67dd19e27b56b304e Mon Sep 17 00:00:00 2001 From: Doug Sisk Date: Thu, 24 Dec 2015 13:26:02 -0700 Subject: [PATCH 29/69] Incorrect spelling --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb4e740..a96d78a 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ The Backup Manager will make use of Laravel's database configuration. But, it wo #### Lumen Configuration -To install into a Lumen project, first do the composer install then add *ONE* of the following service providers to your `boostrap/app.php`. +To install into a Lumen project, first do the composer install then add *ONE* of the following service providers to your `bootstrap/app.php`. ```php // FOR LUMEN 5.0 ONLY From 163102eb80a7580c125a77b25dbd380f952f7147 Mon Sep 17 00:00:00 2001 From: Doug Sisk Date: Thu, 24 Dec 2015 13:27:10 -0700 Subject: [PATCH 30/69] Configuration file has to be manually loaded --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a96d78a..51a54fc 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ The Backup Manager will make use of Laravel's database configuration. But, it wo #### Lumen Configuration -To install into a Lumen project, first do the composer install then add *ONE* of the following service providers to your `bootstrap/app.php`. +To install into a Lumen project, first do the composer install then add the configuration file loader and *ONE* of the following service providers to your `bootstrap/app.php`. ```php // FOR LUMEN 5.0 ONLY From c775f41ed8da26ab85cd203e520ca264d4e730ed Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Mon, 11 Jan 2016 09:24:57 +0100 Subject: [PATCH 31/69] add compatibility for symfony process library 2 or 3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 65bd23e..a3eca06 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "require": { "backup-manager/backup-manager": "^1.0", "php": ">=5.5.0", - "symfony/process": "^2.0", + "symfony/process": "^2.0||^3.0", "illuminate/support": "^4.0||^5.0", "illuminate/container": "^4.0||^5.0", "illuminate/console": "^4.0||^5.0" From d48ec3314acfc48ff8d50352c1f2cedf2cb6b453 Mon Sep 17 00:00:00 2001 From: Devon Zara Date: Sat, 6 Feb 2016 05:49:27 +0000 Subject: [PATCH 32/69] Update for Symfony 3 components --- src/AutoComplete.php | 39 +++++++++++++++++++++++++++++++++- src/Laravel4Compatibility.php | 12 ++++++++++- src/Laravel50Compatibility.php | 12 ++++++++++- src/Laravel51Compatibility.php | 12 ++++++++++- 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/src/AutoComplete.php b/src/AutoComplete.php index e9d8add..bde69f1 100644 --- a/src/AutoComplete.php +++ b/src/AutoComplete.php @@ -1,7 +1,11 @@ useSymfontDialog($dialog, $list, $default, $validation); + } catch (InvalidArgumentException $error) { + // + } finally { + return $this->useSymfonyQuestion($dialog, $default, $validation); + } + } + + /** + * @param $dialog + * @param array $list + * @param null $default + * @return mixed + */ + protected function useSymfontDialog($dialog, array $list, $default = null, $validation) { $helper = $this->getHelperSet()->get('dialog'); - return $helper->askAndValidate($this->output, "{$dialog}", $validation, false, $default, $list); + + return $helper->askAndValidate( + $this->output, "{$dialog}", $validation, false, $default, $list + ); + } + + /** + * @param $dialog + * @param null $default + * @return mixed + */ + protected function useSymfonyQuestion($dialog, $default = null, $validation) { + $question = new Question($dialog . ' ', $default); + $question->setValidator($validation); + $helper = $this->getHelper('question'); + + return $helper->ask($this->input, $this->output, $question); } } diff --git a/src/Laravel4Compatibility.php b/src/Laravel4Compatibility.php index 95fa44d..4d03e68 100644 --- a/src/Laravel4Compatibility.php +++ b/src/Laravel4Compatibility.php @@ -1,5 +1,8 @@ getHelperSet()->get('table'); + try { + $table = $this->getHelperSet()->get('table'); + } catch (InvalidArgumentException $error) { + // + } finally { + $table = new Table($this->output); + } + $table->setHeaders($headers); $table->setRows($rows); $table->render($this->output); diff --git a/src/Laravel50Compatibility.php b/src/Laravel50Compatibility.php index abe02b2..69de9ed 100644 --- a/src/Laravel50Compatibility.php +++ b/src/Laravel50Compatibility.php @@ -1,5 +1,8 @@ getHelperSet()->get('table'); + try { + $table = $this->getHelperSet()->get('table'); + } catch (InvalidArgumentException $error) { + // + } finally { + $table = new Table($this->output); + } + $table->setHeaders($headers); $table->setRows($rows); $table->render($this->output); diff --git a/src/Laravel51Compatibility.php b/src/Laravel51Compatibility.php index 551f34f..ae0cccc 100644 --- a/src/Laravel51Compatibility.php +++ b/src/Laravel51Compatibility.php @@ -1,5 +1,8 @@ getHelperSet()->get('table'); + try { + $table = $this->getHelperSet()->get('table'); + } catch (InvalidArgumentException $error) { + // + } finally { + $table = new Table($this->output); + } + $table->setHeaders($headers); $table->setRows($rows); $table->render($this->output); From 03513fecbfac45551d501f21d2183c3719e86afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mahe=CC=81?= Date: Mon, 8 Feb 2016 11:18:15 +0700 Subject: [PATCH 33/69] Fix compatibility with backup-manager v1.1.1 --- src/DbBackupCommand.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/DbBackupCommand.php b/src/DbBackupCommand.php index ce5708b..e044d15 100644 --- a/src/DbBackupCommand.php +++ b/src/DbBackupCommand.php @@ -1,5 +1,6 @@ validateArguments(); } + $destinations = [ + new Destination( + $this->option('destination'), + $this->option('destinationPath') + ) + ]; + $this->info('Dumping database and uploading...'); $this->backupProcedure->run( $this->option('database'), - $this->option('destination'), - $this->option('destinationPath'), + $destinations, $this->option('compression') ); From 344b0ef00aa00f7c266d2866161cf6fa05c4b3e0 Mon Sep 17 00:00:00 2001 From: Piet de Vries Date: Tue, 22 Mar 2016 12:54:12 +0100 Subject: [PATCH 34/69] Support for files without extension in db:list Added support for files without extension in db:list. --- src/DbListCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DbListCommand.php b/src/DbListCommand.php index 9e207d8..9bbcbe9 100644 --- a/src/DbListCommand.php +++ b/src/DbListCommand.php @@ -76,7 +76,7 @@ public function fire() { if ($file['type'] == 'dir') continue; $rows[] = [ $file['basename'], - $file['extension'], + key_exists('extension', $file) ? $file['extension'] : null, $this->formatBytes($file['size']), date('D j Y H:i:s', $file['timestamp']) ]; From 4b079ec13a082d694fd92d9850af77bcf641ff32 Mon Sep 17 00:00:00 2001 From: Piet de Vries Date: Tue, 22 Mar 2016 13:08:40 +0100 Subject: [PATCH 35/69] Support for files without extension in db:restore --- src/DbRestoreCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DbRestoreCommand.php b/src/DbRestoreCommand.php index 8951c58..ead624e 100644 --- a/src/DbRestoreCommand.php +++ b/src/DbRestoreCommand.php @@ -176,7 +176,7 @@ private function askSourcePath() { if ($file['type'] == 'dir') continue; $rows[] = [ $file['basename'], - $file['extension'], + key_exists('extension', $file) ? $file['extension'] : null, $this->formatBytes($file['size']), date('D j Y H:i:s', $file['timestamp']) ]; From 8efb138051fe8d01f733d450e7e8fdda97740156 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 15 Nov 2016 12:31:21 +0100 Subject: [PATCH 36/69] bump version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 51a54fc..0892431 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Laravel Driver for the Database Backup Manager +# Laravel Driver for the Database Backup Manager 1.1.1 This package pulls in the framework agnostic [Backup Manager](https://github.com/backup-manager/backup-manager) and provides seamless integration with **Laravel**. From a7f455358c8940c4059bb1edf62305337aef3833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D0=BD=D1=8F?= Date: Thu, 5 Jan 2017 19:30:14 +0200 Subject: [PATCH 37/69] Make trait for absolutely identical code. Add key "ignoreTables" for databases with mysql driver. --- src/GetDatabaseConfig.php | 45 ++++++++++++++++++++++++++++++++ src/Laravel4ServiceProvider.php | 33 +---------------------- src/Laravel50ServiceProvider.php | 29 +------------------- src/Laravel5ServiceProvider.php | 29 +------------------- src/Lumen50ServiceProvider.php | 29 +------------------- src/LumenServiceProvider.php | 29 +------------------- 6 files changed, 50 insertions(+), 144 deletions(-) create mode 100644 src/GetDatabaseConfig.php diff --git a/src/GetDatabaseConfig.php b/src/GetDatabaseConfig.php new file mode 100644 index 0000000..42a33e8 --- /dev/null +++ b/src/GetDatabaseConfig.php @@ -0,0 +1,45 @@ + $connection['driver'], + 'host' => $connection['host'], + 'port' => $port, + 'user' => $connection['username'], + 'pass' => $connection['password'], + 'database' => $connection['database'], + 'ignoreTables' => $connection['driver'] === 'mysql' && isset($connection['ignoreTables']) + ? $connection['ignoreTables'] : null, + ]; + }, $connections); + return new Config($mapped); + } +} diff --git a/src/Laravel4ServiceProvider.php b/src/Laravel4ServiceProvider.php index a030cdf..1783170 100644 --- a/src/Laravel4ServiceProvider.php +++ b/src/Laravel4ServiceProvider.php @@ -13,6 +13,7 @@ * @package BackupManager\Laravel */ class Laravel4ServiceProvider extends ServiceProvider { + use GetDatabaseConfig; /** @var bool */ protected $defer = true; @@ -122,36 +123,4 @@ public function provides() { \BackupManager\ShellProcessing\ShellProcessor::class, ]; } - - /** - * @param $connections - * @return Config - */ - private function getDatabaseConfig($connections) { - $mapped = array_map(function ($connection) { - if ( ! in_array($connection['driver'], ['mysql', 'pgsql'])) { - return; - } - - if (isset($connection['port'])) { - $port = $connection['port']; - } else { - if ($connection['driver'] == 'mysql') { - $port = '3306'; - } elseif ($connection['driver'] == 'pgsql') { - $port = '5432'; - } - } - - return [ - 'type' => $connection['driver'], - 'host' => $connection['host'], - 'port' => $port, - 'user' => $connection['username'], - 'pass' => $connection['password'], - 'database' => $connection['database'], - ]; - }, $connections); - return new Config($mapped); - } } diff --git a/src/Laravel50ServiceProvider.php b/src/Laravel50ServiceProvider.php index 974f52e..fafc010 100644 --- a/src/Laravel50ServiceProvider.php +++ b/src/Laravel50ServiceProvider.php @@ -13,6 +13,7 @@ * @package BackupManager\Laravel */ class Laravel50ServiceProvider extends ServiceProvider { + use GetDatabaseConfig; protected $defer = true; @@ -123,32 +124,4 @@ public function provides() { \BackupManager\ShellProcessing\ShellProcessor::class, ]; } - - private function getDatabaseConfig($connections) { - $mapped = array_map(function ($connection) { - if ( ! in_array($connection['driver'], ['mysql', 'pgsql'])) { - return; - } - - if (isset($connection['port'])) { - $port = $connection['port']; - } else { - if ($connection['driver'] == 'mysql') { - $port = '3306'; - } elseif ($connection['driver'] == 'pgsql') { - $port = '5432'; - } - } - - return [ - 'type' => $connection['driver'], - 'host' => $connection['host'], - 'port' => $port, - 'user' => $connection['username'], - 'pass' => $connection['password'], - 'database' => $connection['database'], - ]; - }, $connections); - return new Config($mapped); - } } diff --git a/src/Laravel5ServiceProvider.php b/src/Laravel5ServiceProvider.php index 143da44..226e325 100644 --- a/src/Laravel5ServiceProvider.php +++ b/src/Laravel5ServiceProvider.php @@ -13,6 +13,7 @@ * @package BackupManager\Laravel */ class Laravel5ServiceProvider extends ServiceProvider { + use GetDatabaseConfig; protected $defer = true; @@ -124,32 +125,4 @@ public function provides() { \BackupManager\ShellProcessing\ShellProcessor::class, ]; } - - private function getDatabaseConfig($connections) { - $mapped = array_map(function ($connection) { - if ( ! in_array($connection['driver'], ['mysql', 'pgsql'])) { - return; - } - - if (isset($connection['port'])) { - $port = $connection['port']; - } else { - if ($connection['driver'] == 'mysql') { - $port = '3306'; - } elseif ($connection['driver'] == 'pgsql') { - $port = '5432'; - } - } - - return [ - 'type' => $connection['driver'], - 'host' => $connection['host'], - 'port' => $port, - 'user' => $connection['username'], - 'pass' => $connection['password'], - 'database' => $connection['database'], - ]; - }, $connections); - return new Config($mapped); - } } diff --git a/src/Lumen50ServiceProvider.php b/src/Lumen50ServiceProvider.php index a808e58..866bd62 100644 --- a/src/Lumen50ServiceProvider.php +++ b/src/Lumen50ServiceProvider.php @@ -13,6 +13,7 @@ * @package BackupManager\Laravel */ class Lumen50ServiceProvider extends ServiceProvider { + use GetDatabaseConfig; protected $defer = true; @@ -113,32 +114,4 @@ public function provides() { \BackupManager\ShellProcessing\ShellProcessor::class, ]; } - - private function getDatabaseConfig($connections) { - $mapped = array_map(function ($connection) { - if ( ! in_array($connection['driver'], ['mysql', 'pgsql'])) { - return; - } - - if (isset($connection['port'])) { - $port = $connection['port']; - } else { - if ($connection['driver'] == 'mysql') { - $port = '3306'; - } elseif ($connection['driver'] == 'pgsql') { - $port = '5432'; - } - } - - return [ - 'type' => $connection['driver'], - 'host' => $connection['host'], - 'port' => $port, - 'user' => $connection['username'], - 'pass' => $connection['password'], - 'database' => $connection['database'], - ]; - }, $connections); - return new Config($mapped); - } } diff --git a/src/LumenServiceProvider.php b/src/LumenServiceProvider.php index 64cec63..1d27a40 100644 --- a/src/LumenServiceProvider.php +++ b/src/LumenServiceProvider.php @@ -13,6 +13,7 @@ * @package BackupManager\Laravel */ class LumenServiceProvider extends ServiceProvider { + use GetDatabaseConfig; protected $defer = true; @@ -114,32 +115,4 @@ public function provides() { \BackupManager\ShellProcessing\ShellProcessor::class, ]; } - - private function getDatabaseConfig($connections) { - $mapped = array_map(function ($connection) { - if ( ! in_array($connection['driver'], ['mysql', 'pgsql'])) { - return; - } - - if (isset($connection['port'])) { - $port = $connection['port']; - } else { - if ($connection['driver'] == 'mysql') { - $port = '3306'; - } elseif ($connection['driver'] == 'pgsql') { - $port = '5432'; - } - } - - return [ - 'type' => $connection['driver'], - 'host' => $connection['host'], - 'port' => $port, - 'user' => $connection['username'], - 'pass' => $connection['password'], - 'database' => $connection['database'], - ]; - }, $connections); - return new Config($mapped); - } } From ef968a54d5f3b98063f54210d835fa5350a81450 Mon Sep 17 00:00:00 2001 From: soulofmachines Date: Mon, 27 Mar 2017 20:43:44 +0300 Subject: [PATCH 38/69] return inside finally block --- src/AutoComplete.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/AutoComplete.php b/src/AutoComplete.php index bde69f1..d215530 100644 --- a/src/AutoComplete.php +++ b/src/AutoComplete.php @@ -30,9 +30,8 @@ public function autocomplete($dialog, array $list, $default = null) { return $this->useSymfontDialog($dialog, $list, $default, $validation); } catch (InvalidArgumentException $error) { // - } finally { - return $this->useSymfonyQuestion($dialog, $default, $validation); } + return $this->useSymfonyQuestion($dialog, $default, $validation); } /** From fc5d3144cceef9bc27cd0f515b3853fd912eaa88 Mon Sep 17 00:00:00 2001 From: Raza Mehdi Date: Fri, 30 Jun 2017 23:24:54 +0500 Subject: [PATCH 39/69] Update package --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 51a54fc..5530806 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Then, you'll need to select the appropriate packages for the adapters that you w composer require league/flysystem-aws-s3-v3 # to support dropbox -composer require league/flysystem-dropbox +composer require srmklive/flysystem-dropbox-v2 # to support rackspace composer require league/flysystem-rackspace From d922972af50eb58eadb535c7eed74dbb5b22e1b9 Mon Sep 17 00:00:00 2001 From: Laurence Ioannou Date: Mon, 31 Jul 2017 00:31:32 +0100 Subject: [PATCH 40/69] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5530806..370d4c7 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ It's possible to schedule backups using Laravel's scheduler. */ protected function schedule(Schedule $schedule) { $date = Carbon::now()->toW3cString(); - $environment = env('APP_ENV'); + $environment = config('app.env'); $schedule->command( "db:backup --database=mysql --destination=s3 --destinationPath=/{$environment}/projectname_{$environment}_{$date} --compression=gzip" )->twiceDaily(13,21); From acbb42ae95639c9bd5cf7c2106d6e9594484bdf6 Mon Sep 17 00:00:00 2001 From: Laurence Date: Mon, 31 Jul 2017 10:15:58 +0000 Subject: [PATCH 41/69] add timestamp option --- README.md | 23 +++++++++++------------ src/DbBackupCommand.php | 17 +++++++++++++---- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 370d4c7..d6621d7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Laravel Driver for the Database Backup Manager -This package pulls in the framework agnostic [Backup Manager](https://github.com/backup-manager/backup-manager) and provides seamless integration with **Laravel**. +This package pulls in the framework agnostic [Backup Manager](https://github.com/backup-manager/backup-manager) and provides seamless integration with **Laravel**. [Watch a video tour](https://www.youtube.com/watch?v=vWXy0R8OavM) to get an idea what is possible with this package. @@ -80,7 +80,7 @@ BackupManager\Laravel\Laravel5ServiceProvider::class, Publish the storage configuration file. -```php +```php php artisan vendor:publish --provider="BackupManager\Laravel\Laravel5ServiceProvider" ``` @@ -129,10 +129,10 @@ All will prompt you with simple questions to successfully execute the command. **Example Command for 24hour scheduled cronjob** ``` -php artisan db:backup --database=mysql --destination=dropbox --destinationPath=`date +\%Y/%d-%m-%Y` --compression=gzip +php artisan db:backup --database=mysql --destination=dropbox --destinationPath=project --timestamp="d-m-Y" --compression=gzip ``` -This command will backup your database to dropbox using mysql and gzip compresion in path /backups/YEAR/DATE.gz (ex: /backups/2015/29-10-2015.gz) +This command will backup your database to dropbox using mysql and gzip compresion in path /backups/project/DATE.gz (ex: /backups/project/31-7-2015.gz) ### Scheduling Backups @@ -145,15 +145,14 @@ It's possible to schedule backups using Laravel's scheduler. * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ -protected function schedule(Schedule $schedule) { - $date = Carbon::now()->toW3cString(); - $environment = config('app.env'); - $schedule->command( - "db:backup --database=mysql --destination=s3 --destinationPath=/{$environment}/projectname_{$environment}_{$date} --compression=gzip" - )->twiceDaily(13,21); -} + protected function schedule(Schedule $schedule) { + $environment = config('app.env'); + $schedule->command( + "db:backup --database=mysql --destination=s3 --destinationPath=/{$environment}/projectname --timestamp="Y_m_d_H_i_s" --compression=gzip" + )->twiceDaily(13,21); + } ``` - + ### Contribution Guidelines We recommend using the vagrant configuration supplied with this package for development and contribution. Simply install VirtualBox, Vagrant, and Ansible then run `vagrant up` in the root folder. A virtualmachine specifically designed for development of the package will be built and launched for you. diff --git a/src/DbBackupCommand.php b/src/DbBackupCommand.php index e044d15..ef7e1e8 100644 --- a/src/DbBackupCommand.php +++ b/src/DbBackupCommand.php @@ -35,6 +35,13 @@ class DbBackupCommand extends Command { */ private $required = ['database', 'destination', 'destinationPath', 'compression']; + /** + * Optional timestamp. + * + * @var string + */ + private $timestamp; + /** * The missing arguments. * @@ -80,6 +87,8 @@ public function __construct(BackupProcedure $backupProcedure, DatabaseProvider $ * @return mixed */ public function fire() { + $this->timestamp = date($this->option('timestamp')); + if ($this->isMissingArguments()) { $this->displayMissingArguments(); $this->promptForMissingArgumentValues(); @@ -89,11 +98,10 @@ public function fire() { $destinations = [ new Destination( $this->option('destination'), - $this->option('destinationPath') + $this->option('destinationPath') . $this->timestamp ) ]; - $this->info('Dumping database and uploading...'); $this->backupProcedure->run( $this->option('database'), $destinations, @@ -106,7 +114,7 @@ public function fire() { $this->option('database'), $this->option('compression'), $this->option('destination'), - $root .DIRECTORY_SEPARATOR. $this->option('destinationPath') + $destinations[0]->destinationPath() )); } @@ -191,7 +199,7 @@ private function validateArguments() { $this->info(sprintf('Do you want to create a backup of %s, store it on %s at %s and compress it to %s?', $this->option('database'), $this->option('destination'), - $root . $this->option('destinationPath'), + $root . $this->option('destinationPath') . $this->timestamp, $this->option('compression') )); $this->line(''); @@ -224,6 +232,7 @@ protected function getOptions() { ['destination', null, InputOption::VALUE_OPTIONAL, 'Destination configuration name', null], ['destinationPath', null, InputOption::VALUE_OPTIONAL, 'File destination path', null], ['compression', null, InputOption::VALUE_OPTIONAL, 'Compression type', null], + ['timestamp', null, InputOption::VALUE_OPTIONAL, 'Append timestamp to filename', null], ]; } } From dce9280fc6a2e98e58f933e1c40451e2dd1c0866 Mon Sep 17 00:00:00 2001 From: Laurence Date: Mon, 31 Jul 2017 10:19:22 +0000 Subject: [PATCH 42/69] include info line --- src/DbBackupCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DbBackupCommand.php b/src/DbBackupCommand.php index ef7e1e8..e89ca28 100644 --- a/src/DbBackupCommand.php +++ b/src/DbBackupCommand.php @@ -102,6 +102,7 @@ public function fire() { ) ]; + $this->info('Dumping database and uploading...'); $this->backupProcedure->run( $this->option('database'), $destinations, From 343885742036ff6a20850190c9bfcfa697087a94 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Mon, 31 Jul 2017 14:23:01 +0200 Subject: [PATCH 43/69] add 1.2.0 documentation header --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b2d669..18626bb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Laravel Driver for the Database Backup Manager 1.1.1 +# Laravel Driver for the Database Backup Manager 1.2.0 This package pulls in the framework agnostic [Backup Manager](https://github.com/backup-manager/backup-manager) and provides seamless integration with **Laravel**. From aff0ed69baf659540497713376c0b5d9fd6e269e Mon Sep 17 00:00:00 2001 From: armandsar Date: Wed, 30 Aug 2017 19:50:31 +0300 Subject: [PATCH 44/69] add laravel 5.5 compatibility --- README.md | 5 +- src/Laravel55Compatibility.php | 35 ++++++++ src/Laravel55DbBackupCommand.php | 11 +++ src/Laravel55DbListCommand.php | 11 +++ src/Laravel55DbRestoreCommand.php | 11 +++ src/Laravel55ServiceProvider.php | 128 ++++++++++++++++++++++++++++++ 6 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 src/Laravel55Compatibility.php create mode 100644 src/Laravel55DbBackupCommand.php create mode 100644 src/Laravel55DbListCommand.php create mode 100644 src/Laravel55DbRestoreCommand.php create mode 100644 src/Laravel55ServiceProvider.php diff --git a/README.md b/README.md index 18626bb..01b8181 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,11 @@ To install into a Laravel project, first do the composer install then add *ONE * // FOR LARAVEL 5.0 ONLY BackupManager\Laravel\Laravel50ServiceProvider::class, -// FOR LARAVEL 5.1 AND ABOVE +// FOR LARAVEL 5.1 - 5.4 BackupManager\Laravel\Laravel5ServiceProvider::class, + +// FOR LARAVEL 5.5 +BackupManager\Laravel\Laravel55ServiceProvider::class, ``` Publish the storage configuration file. diff --git a/src/Laravel55Compatibility.php b/src/Laravel55Compatibility.php new file mode 100644 index 0000000..c308861 --- /dev/null +++ b/src/Laravel55Compatibility.php @@ -0,0 +1,35 @@ +getHelperSet()->get('table'); + } catch (InvalidArgumentException $error) { + // + } finally { + $table = new Table($this->output); + } + + $table->setHeaders($headers); + $table->setRows($rows); + $table->render($this->output); + } + + public function handle() + { + $this->fire(); + } +} diff --git a/src/Laravel55DbBackupCommand.php b/src/Laravel55DbBackupCommand.php new file mode 100644 index 0000000..fba0c69 --- /dev/null +++ b/src/Laravel55DbBackupCommand.php @@ -0,0 +1,11 @@ +publishes([$configPath => config_path('backup-manager.php')], 'config'); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() { + $configPath = __DIR__ . '/../config/backup-manager.php'; + $this->mergeConfigFrom($configPath, 'backup-manager'); + $this->registerFilesystemProvider(); + $this->registerDatabaseProvider(); + $this->registerCompressorProvider(); + $this->registerShellProcessor(); + $this->registerArtisanCommands(); + } + + /** + * Register the filesystem provider. + * + * @return void + */ + private function registerFilesystemProvider() { + $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { + $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); + $provider->add(new Filesystems\Awss3Filesystem); + $provider->add(new Filesystems\GcsFilesystem); + $provider->add(new Filesystems\DropboxFilesystem); + $provider->add(new Filesystems\FtpFilesystem); + $provider->add(new Filesystems\LocalFilesystem); + $provider->add(new Filesystems\RackspaceFilesystem); + $provider->add(new Filesystems\SftpFilesystem); + return $provider; + }); + } + + /** + * Register the database provider. + * + * @return void + */ + private function registerDatabaseProvider() { + $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) { + $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections'])); + $provider->add(new Databases\MysqlDatabase); + $provider->add(new Databases\PostgresqlDatabase); + return $provider; + }); + } + + /** + * Register the compressor provider. + * + * @return void + */ + private function registerCompressorProvider() { + $this->app->bind(\BackupManager\Compressors\CompressorProvider::class, function () { + $provider = new Compressors\CompressorProvider; + $provider->add(new Compressors\GzipCompressor); + $provider->add(new Compressors\NullCompressor); + return $provider; + }); + } + + /** + * Register the filesystem provider. + * + * @return void + */ + private function registerShellProcessor() { + $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { + return new ShellProcessor(new Process('', null, null, null, null)); + }); + } + + /** + * Register the artisan commands. + * + * @return void + */ + private function registerArtisanCommands() { + $this->commands([ + \BackupManager\Laravel\Laravel55DbBackupCommand::class, + \BackupManager\Laravel\Laravel55DbRestoreCommand::class, + \BackupManager\Laravel\Laravel55DbListCommand::class, + ]); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() { + return [ + \BackupManager\Filesystems\FilesystemProvider::class, + \BackupManager\Databases\DatabaseProvider::class, + \BackupManager\ShellProcessing\ShellProcessor::class, + ]; + } +} From b415a594bf3eb8d7c6acc35f03a44b817dd692db Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Fri, 8 Sep 2017 14:13:35 +0200 Subject: [PATCH 45/69] bump to 1.2.1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 01b8181..9835301 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Laravel Driver for the Database Backup Manager 1.2.0 +# Laravel Driver for the Database Backup Manager 1.2.1 This package pulls in the framework agnostic [Backup Manager](https://github.com/backup-manager/backup-manager) and provides seamless integration with **Laravel**. From 3f48ebdbcdf06a9b7c57b0f864fca26570f54a6b Mon Sep 17 00:00:00 2001 From: PXgamer Date: Mon, 18 Sep 2017 11:40:24 +0100 Subject: [PATCH 46/69] Added Laravel 5.5 auto-discovery meta to the composer.json --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index a3eca06..a3a92e8 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,11 @@ "extra": { "branch-alias": { "dev-master": "1.0-dev" + }, + "laravel": { + "providers": [ + "BackupManager\\Laravel\\Laravel55ServiceProvider" + ] } }, "license": "MIT" From 17a8d6325332114d2317b200deb7fe5a5337ac7b Mon Sep 17 00:00:00 2001 From: James Date: Wed, 20 Sep 2017 10:06:20 -0700 Subject: [PATCH 47/69] Fixes ErrorException in Laravel 5.5 [ErrorException] Declaration of BackupManager\Laravel\Laravel55Compatibility::table($headers, $rows, $style = 'default') should be compati ble with Illuminate\Console\Command::table($headers, $rows, $tableStyle = 'default', array $columnStyles = Array) --- src/Laravel55Compatibility.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Laravel55Compatibility.php b/src/Laravel55Compatibility.php index c308861..6ebc2e3 100644 --- a/src/Laravel55Compatibility.php +++ b/src/Laravel55Compatibility.php @@ -9,12 +9,13 @@ */ trait Laravel55Compatibility { /** - * @param array $headers - * @param array $rows - * @internal param string $style + * @param $headers + * @param $rows + * @param string $style + * @param array $columnStyles * @return void */ - public function table($headers, $rows, $style = 'default') { + public function table($headers, $rows, $style = 'default', array $columnStyles = []) { try { $table = $this->getHelperSet()->get('table'); } catch (InvalidArgumentException $error) { From 091374d1da68af269b19c302553e9cea560b5645 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Thu, 28 Sep 2017 07:28:29 +0200 Subject: [PATCH 48/69] bump to 1.2.2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9835301..e0a6a49 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Laravel Driver for the Database Backup Manager 1.2.1 +# Laravel Driver for the Database Backup Manager 1.2.2 This package pulls in the framework agnostic [Backup Manager](https://github.com/backup-manager/backup-manager) and provides seamless integration with **Laravel**. From 0d2a574817f8cc395ee0dbd7ca60375e61b2f679 Mon Sep 17 00:00:00 2001 From: Armands Leinieks Date: Wed, 7 Feb 2018 21:03:33 +0200 Subject: [PATCH 49/69] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a3a92e8..6f50266 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "require": { "backup-manager/backup-manager": "^1.0", "php": ">=5.5.0", - "symfony/process": "^2.0||^3.0", + "symfony/process": "^2.0||^3.0||^4.0", "illuminate/support": "^4.0||^5.0", "illuminate/container": "^4.0||^5.0", "illuminate/console": "^4.0||^5.0" From 12aed7fa11161a4707164c36b0f5f5be0802f4da Mon Sep 17 00:00:00 2001 From: Tint Naing Win Date: Mon, 12 Feb 2018 10:53:36 +0630 Subject: [PATCH 50/69] Added DropboxV2Filesystem --- config/backup-manager.php | 2 +- src/Laravel4ServiceProvider.php | 1 + src/Laravel50ServiceProvider.php | 1 + src/Laravel55ServiceProvider.php | 1 + src/Laravel5ServiceProvider.php | 1 + src/Lumen50ServiceProvider.php | 1 + src/LumenServiceProvider.php | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/backup-manager.php b/config/backup-manager.php index f2dd3dc..25fff2f 100644 --- a/config/backup-manager.php +++ b/config/backup-manager.php @@ -30,7 +30,7 @@ 'root' => '', ], 'dropbox' => [ - 'type' => 'Dropbox', + 'type' => 'DropboxV2', 'token' => '', 'key' => '', 'secret' => '', diff --git a/src/Laravel4ServiceProvider.php b/src/Laravel4ServiceProvider.php index 1783170..706ed09 100644 --- a/src/Laravel4ServiceProvider.php +++ b/src/Laravel4ServiceProvider.php @@ -51,6 +51,7 @@ private function registerFilesystemProvider() { $provider->add(new Filesystems\Awss3Filesystem); $provider->add(new Filesystems\GcsFilesystem); $provider->add(new Filesystems\DropboxFilesystem); + $provider->add(new Filesystems\DropboxV2Filesystem); $provider->add(new Filesystems\FtpFilesystem); $provider->add(new Filesystems\LocalFilesystem); $provider->add(new Filesystems\RackspaceFilesystem); diff --git a/src/Laravel50ServiceProvider.php b/src/Laravel50ServiceProvider.php index fafc010..3fb61f3 100644 --- a/src/Laravel50ServiceProvider.php +++ b/src/Laravel50ServiceProvider.php @@ -52,6 +52,7 @@ private function registerFilesystemProvider() { $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); $provider->add(new Filesystems\Awss3Filesystem); $provider->add(new Filesystems\DropboxFilesystem); + $provider->add(new Filesystems\DropboxV2Filesystem); $provider->add(new Filesystems\FtpFilesystem); $provider->add(new Filesystems\LocalFilesystem); $provider->add(new Filesystems\RackspaceFilesystem); diff --git a/src/Laravel55ServiceProvider.php b/src/Laravel55ServiceProvider.php index eb9586f..f0e7bd8 100644 --- a/src/Laravel55ServiceProvider.php +++ b/src/Laravel55ServiceProvider.php @@ -53,6 +53,7 @@ private function registerFilesystemProvider() { $provider->add(new Filesystems\Awss3Filesystem); $provider->add(new Filesystems\GcsFilesystem); $provider->add(new Filesystems\DropboxFilesystem); + $provider->add(new Filesystems\DropboxV2Filesystem); $provider->add(new Filesystems\FtpFilesystem); $provider->add(new Filesystems\LocalFilesystem); $provider->add(new Filesystems\RackspaceFilesystem); diff --git a/src/Laravel5ServiceProvider.php b/src/Laravel5ServiceProvider.php index 226e325..e54afb5 100644 --- a/src/Laravel5ServiceProvider.php +++ b/src/Laravel5ServiceProvider.php @@ -53,6 +53,7 @@ private function registerFilesystemProvider() { $provider->add(new Filesystems\Awss3Filesystem); $provider->add(new Filesystems\GcsFilesystem); $provider->add(new Filesystems\DropboxFilesystem); + $provider->add(new Filesystems\DropboxV2Filesystem); $provider->add(new Filesystems\FtpFilesystem); $provider->add(new Filesystems\LocalFilesystem); $provider->add(new Filesystems\RackspaceFilesystem); diff --git a/src/Lumen50ServiceProvider.php b/src/Lumen50ServiceProvider.php index 866bd62..6c878ca 100644 --- a/src/Lumen50ServiceProvider.php +++ b/src/Lumen50ServiceProvider.php @@ -42,6 +42,7 @@ private function registerFilesystemProvider() { $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); $provider->add(new Filesystems\Awss3Filesystem); $provider->add(new Filesystems\DropboxFilesystem); + $provider->add(new Filesystems\DropboxV2Filesystem); $provider->add(new Filesystems\FtpFilesystem); $provider->add(new Filesystems\LocalFilesystem); $provider->add(new Filesystems\RackspaceFilesystem); diff --git a/src/LumenServiceProvider.php b/src/LumenServiceProvider.php index 1d27a40..b971f74 100644 --- a/src/LumenServiceProvider.php +++ b/src/LumenServiceProvider.php @@ -43,6 +43,7 @@ private function registerFilesystemProvider() { $provider->add(new Filesystems\Awss3Filesystem); $provider->add(new Filesystems\GcsFilesystem); $provider->add(new Filesystems\DropboxFilesystem); + $provider->add(new Filesystems\DropboxV2Filesystem); $provider->add(new Filesystems\FtpFilesystem); $provider->add(new Filesystems\LocalFilesystem); $provider->add(new Filesystems\RackspaceFilesystem); From 6a69ee593cf4d05acde49c76f1b2effa1c2be29d Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Mon, 12 Feb 2018 13:59:36 +0100 Subject: [PATCH 51/69] upgrade to laravel 5.6 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e0a6a49..24c5837 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Laravel Driver for the Database Backup Manager 1.2.2 +# Laravel Driver for the Database Backup Manager 1.3.0 This package pulls in the framework agnostic [Backup Manager](https://github.com/backup-manager/backup-manager) and provides seamless integration with **Laravel**. From 672e4a8c2c530af1e014e4f826214c59f0ae4bba Mon Sep 17 00:00:00 2001 From: madworks Date: Wed, 11 Apr 2018 23:13:00 +0900 Subject: [PATCH 52/69] Initialized s3 config by environment variables. --- config/backup-manager.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/backup-manager.php b/config/backup-manager.php index 25fff2f..3811221 100644 --- a/config/backup-manager.php +++ b/config/backup-manager.php @@ -7,10 +7,10 @@ ], 's3' => [ 'type' => 'AwsS3', - 'key' => '', - 'secret' => '', - 'region' => 'us-east-1', - 'bucket' => '', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION'), + 'bucket' => env('AWS_BUCKET'), 'root' => '', ], 'gcs' => [ From 4c2875ee73ebeaf464cf47e88ed0dd57040f1306 Mon Sep 17 00:00:00 2001 From: Panayiotis Date: Thu, 7 Jun 2018 17:31:51 +0300 Subject: [PATCH 53/69] Lumen 5.5 Service Provider --- README.md | 6 +- src/Lumen55ServiceProvider.php | 118 +++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 src/Lumen55ServiceProvider.php diff --git a/README.md b/README.md index 24c5837..bf08e89 100644 --- a/README.md +++ b/README.md @@ -98,9 +98,13 @@ To install into a Lumen project, first do the composer install then add the conf $app->configure('backup-manager'); $app->register(BackupManager\Laravel\Lumen50ServiceProvider::class); -// FOR LUMEN 5.1 AND ABOVE +// FOR LUMEN 5.1 - 5.4 $app->configure('backup-manager'); $app->register(BackupManager\Laravel\LumenServiceProvider::class); + +// FOR LUMEN 5.5 AND ABOVE +$app->configure('backup-manager'); +$app->register(BackupManager\Laravel\Lumen55ServiceProvider::class); ``` Copy the `vendor/backup-manager/laravel/config/backup-manager.php` file to `config/backup-manager.php` and configure it to suit your needs. diff --git a/src/Lumen55ServiceProvider.php b/src/Lumen55ServiceProvider.php new file mode 100644 index 0000000..3f88700 --- /dev/null +++ b/src/Lumen55ServiceProvider.php @@ -0,0 +1,118 @@ +mergeConfigFrom($configPath, 'backup-manager'); + $this->registerFilesystemProvider(); + $this->registerDatabaseProvider(); + $this->registerCompressorProvider(); + $this->registerShellProcessor(); + $this->registerArtisanCommands(); + } + + /** + * Register the filesystem provider. + * + * @return void + */ + private function registerFilesystemProvider() { + $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { + $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); + $provider->add(new Filesystems\Awss3Filesystem); + $provider->add(new Filesystems\DropboxFilesystem); + $provider->add(new Filesystems\DropboxV2Filesystem); + $provider->add(new Filesystems\FtpFilesystem); + $provider->add(new Filesystems\LocalFilesystem); + $provider->add(new Filesystems\RackspaceFilesystem); + $provider->add(new Filesystems\SftpFilesystem); + return $provider; + }); + } + + /** + * Register the database provider. + * + * @return void + */ + private function registerDatabaseProvider() { + $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) { + $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections'])); + $provider->add(new Databases\MysqlDatabase); + $provider->add(new Databases\PostgresqlDatabase); + return $provider; + }); + } + + /** + * Register the compressor provider. + * + * @return void + */ + private function registerCompressorProvider() { + $this->app->bind(\BackupManager\Compressors\CompressorProvider::class, function () { + $provider = new Compressors\CompressorProvider; + $provider->add(new Compressors\GzipCompressor); + $provider->add(new Compressors\NullCompressor); + return $provider; + }); + } + + /** + * Register the filesystem provider. + * + * @return void + */ + private function registerShellProcessor() { + $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { + return new ShellProcessor(new Process('')); + }); + } + + /** + * Register the artisan commands. + * + * @return void + */ + private function registerArtisanCommands() { + $this->commands([ + \BackupManager\Laravel\Laravel55DbBackupCommand::class, + \BackupManager\Laravel\Laravel55DbRestoreCommand::class, + \BackupManager\Laravel\Laravel55DbListCommand::class, + ]); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() { + return [ + \BackupManager\Filesystems\FilesystemProvider::class, + \BackupManager\Databases\DatabaseProvider::class, + \BackupManager\ShellProcessing\ShellProcessor::class, + ]; + } +} From 369782a7814f58e740b2d3b35c719facb287af3e Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Mon, 18 Jun 2018 11:20:25 +0200 Subject: [PATCH 54/69] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bf08e89..f7874f6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Laravel Driver for the Database Backup Manager 1.3.0 +# Laravel Driver for the Database Backup Manager 1.3.1 This package pulls in the framework agnostic [Backup Manager](https://github.com/backup-manager/backup-manager) and provides seamless integration with **Laravel**. From 78a52e15dd0e57c8562d3c5d6cfaad16bab73477 Mon Sep 17 00:00:00 2001 From: Robbie <13571547+robbielove@users.noreply.github.com> Date: Sun, 30 Dec 2018 14:22:07 +1000 Subject: [PATCH 55/69] Update GetDatabaseConfig.php add compatibility for mysql 8.0 where column-statistics is not present anymore and will cause backups to fail, this change is needed because backup manager allows extra params and it is possible to set `--column-statistics=0`, however backup-manager/laravel just passes the config from backup-manager - providing no opportunity for these extra params to be included --- src/GetDatabaseConfig.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/GetDatabaseConfig.php b/src/GetDatabaseConfig.php index 42a33e8..6320b88 100644 --- a/src/GetDatabaseConfig.php +++ b/src/GetDatabaseConfig.php @@ -38,6 +38,8 @@ private function getDatabaseConfig($connections) { 'database' => $connection['database'], 'ignoreTables' => $connection['driver'] === 'mysql' && isset($connection['ignoreTables']) ? $connection['ignoreTables'] : null, + // add additional options to dump-command (like '--max-allowed-packet') + 'extraParams' => '--column-statistics=0', ]; }, $connections); return new Config($mapped); From cd7f7684144013ad2b1e9e27a549a45a36ad9ec1 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 3 Sep 2019 21:23:25 +0100 Subject: [PATCH 56/69] Update composer.json --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 6f50266..6882e99 100644 --- a/composer.json +++ b/composer.json @@ -17,9 +17,9 @@ "backup-manager/backup-manager": "^1.0", "php": ">=5.5.0", "symfony/process": "^2.0||^3.0||^4.0", - "illuminate/support": "^4.0||^5.0", - "illuminate/container": "^4.0||^5.0", - "illuminate/console": "^4.0||^5.0" + "illuminate/support": "^4.0||^5.0||^6.0", + "illuminate/container": "^4.0||^5.0||^6.0", + "illuminate/console": "^4.0||^5.0||^6.0" }, "require-dev": { "mockery/mockery": "dev-master", From 2b696bd5e8c2afe8313ce56d68c446c99dc76aba Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sat, 5 Oct 2019 08:40:44 +0800 Subject: [PATCH 57/69] fix: Remove -column-statistics=0 extra params --- src/GetDatabaseConfig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GetDatabaseConfig.php b/src/GetDatabaseConfig.php index 6320b88..fe1fbfd 100644 --- a/src/GetDatabaseConfig.php +++ b/src/GetDatabaseConfig.php @@ -39,7 +39,7 @@ private function getDatabaseConfig($connections) { 'ignoreTables' => $connection['driver'] === 'mysql' && isset($connection['ignoreTables']) ? $connection['ignoreTables'] : null, // add additional options to dump-command (like '--max-allowed-packet') - 'extraParams' => '--column-statistics=0', + 'extraParams' => '', ]; }, $connections); return new Config($mapped); From 5bafa111c0602936ebf2d1de5ddd8a458a221b3e Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sat, 5 Oct 2019 09:42:05 +0800 Subject: [PATCH 58/69] feat: Move extra params to config file --- config/backup-manager.php | 3 +++ src/GetDatabaseConfig.php | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/backup-manager.php b/config/backup-manager.php index 3811221..4787e5d 100644 --- a/config/backup-manager.php +++ b/config/backup-manager.php @@ -58,4 +58,7 @@ 'privateKey' => '', 'root' => '', ], + + // Add additional options to dump-command (like '--max-allowed-packet') + 'command-extra-params' => '', ]; diff --git a/src/GetDatabaseConfig.php b/src/GetDatabaseConfig.php index fe1fbfd..dd0eb77 100644 --- a/src/GetDatabaseConfig.php +++ b/src/GetDatabaseConfig.php @@ -38,8 +38,7 @@ private function getDatabaseConfig($connections) { 'database' => $connection['database'], 'ignoreTables' => $connection['driver'] === 'mysql' && isset($connection['ignoreTables']) ? $connection['ignoreTables'] : null, - // add additional options to dump-command (like '--max-allowed-packet') - 'extraParams' => '', + 'extraParams' => config('backup-manager.command-extra-params'), ]; }, $connections); return new Config($mapped); From 031ad1ec3eaa194e1acd5bf49cd63c2043e98c90 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sat, 5 Oct 2019 21:08:47 +0800 Subject: [PATCH 59/69] feat: Set extra params in env variable --- README.md | 6 ++++++ config/backup-manager.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f7874f6..328b207 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,12 @@ php artisan vendor:publish --provider="BackupManager\Laravel\Laravel5ServiceProv The Backup Manager will make use of Laravel's database configuration. But, it won't know about any connections that might be tied to other environments, so it can be best to just list multiple connections in the `config/database.php` file. +We can also add extra parameters on our backup manager commands by configuring extra params on `.env` file: + +``` +BACKUP_MANAGER_EXTRA_PARAMS="--column-statistics=0 --max-allowed-packet" +``` + #### Lumen Configuration To install into a Lumen project, first do the composer install then add the configuration file loader and *ONE* of the following service providers to your `bootstrap/app.php`. diff --git a/config/backup-manager.php b/config/backup-manager.php index 4787e5d..c06df12 100644 --- a/config/backup-manager.php +++ b/config/backup-manager.php @@ -60,5 +60,5 @@ ], // Add additional options to dump-command (like '--max-allowed-packet') - 'command-extra-params' => '', + 'command-extra-params' => env('BACKUP_MANAGER_EXTRA_PARAMS'), ]; From dc114f1191a7d8a84fc52bebb1163c264d0b3da5 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Tue, 8 Oct 2019 13:51:01 +0200 Subject: [PATCH 60/69] remove version from readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 328b207..035799c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Laravel Driver for the Database Backup Manager 1.3.1 +# Laravel Driver for the Database Backup Manager This package pulls in the framework agnostic [Backup Manager](https://github.com/backup-manager/backup-manager) and provides seamless integration with **Laravel**. From 7d3e7d452cfee8b9800187eb3ffe769682ae1749 Mon Sep 17 00:00:00 2001 From: madworks Date: Sun, 2 Feb 2020 17:41:05 +0900 Subject: [PATCH 61/69] Updated config of "gcs" --- config/backup-manager.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config/backup-manager.php b/config/backup-manager.php index c06df12..5e9e5c2 100644 --- a/config/backup-manager.php +++ b/config/backup-manager.php @@ -15,10 +15,11 @@ ], 'gcs' => [ 'type' => 'Gcs', - 'key' => '', - 'secret' => '', + 'project' => '', + 'keyFilePath' => '', 'bucket' => '', - 'root' => '', + 'root' => '', + 'prefix' => '', ], 'rackspace' => [ 'type' => 'Rackspace', From aecf0f752103d609c2d03f4f15f156a83d7b0408 Mon Sep 17 00:00:00 2001 From: madworks Date: Sun, 2 Feb 2020 17:56:21 +0900 Subject: [PATCH 62/69] Updated README.md for gcs --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 035799c..06ba0c2 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,9 @@ composer require league/flysystem-rackspace # to support sftp composer require league/flysystem-sftp + +# to support gcs +composer require superbalist/flysystem-google-storage ``` #### Laravel 4 Configuration From ea253cd7f1f97f952c4353018a70162b6277d95e Mon Sep 17 00:00:00 2001 From: madworks Date: Sun, 2 Feb 2020 18:00:21 +0900 Subject: [PATCH 63/69] Initialized gcs config by environment variables. --- config/backup-manager.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/backup-manager.php b/config/backup-manager.php index 5e9e5c2..f17036b 100644 --- a/config/backup-manager.php +++ b/config/backup-manager.php @@ -15,11 +15,11 @@ ], 'gcs' => [ 'type' => 'Gcs', - 'project' => '', - 'keyFilePath' => '', - 'bucket' => '', + 'project' => env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'), + 'keyFilePath' => env('GOOGLE_CLOUD_KEY_FILE', null), + 'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET', 'your-bucket'), 'root' => '', - 'prefix' => '', + 'prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', null), ], 'rackspace' => [ 'type' => 'Rackspace', From 8dc21f3a779e19aa06bb5ae95135266f6b1e7e7f Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Mon, 20 Apr 2020 00:10:36 +0800 Subject: [PATCH 64/69] Add support for laravel 7 --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 6882e99..41c56a5 100644 --- a/composer.json +++ b/composer.json @@ -16,10 +16,10 @@ "require": { "backup-manager/backup-manager": "^1.0", "php": ">=5.5.0", - "symfony/process": "^2.0||^3.0||^4.0", - "illuminate/support": "^4.0||^5.0||^6.0", - "illuminate/container": "^4.0||^5.0||^6.0", - "illuminate/console": "^4.0||^5.0||^6.0" + "symfony/process": "^2.0||^3.0||^4.0||^5.0", + "illuminate/support": "^4.0||^5.0||^6.0||^7.0", + "illuminate/container": "^4.0||^5.0||^6.0||^7.0", + "illuminate/console": "^4.0||^5.0||^6.0||^7.0" }, "require-dev": { "mockery/mockery": "dev-master", From d20a3af4cade05c826098745440a2ef3e39553a6 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Thu, 23 Apr 2020 07:00:10 +0800 Subject: [PATCH 65/69] Fix Process::__construct() must be of the type array, string given --- src/Laravel55ServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Laravel55ServiceProvider.php b/src/Laravel55ServiceProvider.php index f0e7bd8..c71dd20 100644 --- a/src/Laravel55ServiceProvider.php +++ b/src/Laravel55ServiceProvider.php @@ -97,7 +97,7 @@ private function registerCompressorProvider() { */ private function registerShellProcessor() { $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { - return new ShellProcessor(new Process('', null, null, null, null)); + return new ShellProcessor(new Process([], null, null, null, null)); }); } From 58ccef9882f97240c86f6d747b240dc16b5c7060 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Thu, 30 Apr 2020 12:49:41 +0200 Subject: [PATCH 66/69] update readme for version 2.0 remove compatibility for old versions --- README.md | 45 ++++------- composer.json | 17 ++-- src/Laravel4Compatibility.php | 30 ------- src/Laravel4DbBackupCommand.php | 11 --- src/Laravel4DbListCommand.php | 11 --- src/Laravel4DbRestoreCommand.php | 11 --- src/Laravel4ServiceProvider.php | 127 ----------------------------- src/Laravel50Compatibility.php | 30 ------- src/Laravel50DbBackupCommand.php | 11 --- src/Laravel50DbListCommand.php | 11 --- src/Laravel50DbRestoreCommand.php | 11 --- src/Laravel50ServiceProvider.php | 128 ----------------------------- src/Laravel51Compatibility.php | 30 ------- src/Laravel5DbBackupCommand.php | 11 --- src/Laravel5DbListCommand.php | 11 --- src/Laravel5DbRestoreCommand.php | 11 --- src/Laravel5ServiceProvider.php | 129 ------------------------------ src/Lumen50ServiceProvider.php | 118 --------------------------- src/LumenServiceProvider.php | 119 --------------------------- 19 files changed, 22 insertions(+), 850 deletions(-) delete mode 100644 src/Laravel4Compatibility.php delete mode 100644 src/Laravel4DbBackupCommand.php delete mode 100644 src/Laravel4DbListCommand.php delete mode 100644 src/Laravel4DbRestoreCommand.php delete mode 100644 src/Laravel4ServiceProvider.php delete mode 100644 src/Laravel50Compatibility.php delete mode 100644 src/Laravel50DbBackupCommand.php delete mode 100644 src/Laravel50DbListCommand.php delete mode 100644 src/Laravel50DbRestoreCommand.php delete mode 100644 src/Laravel50ServiceProvider.php delete mode 100644 src/Laravel51Compatibility.php delete mode 100644 src/Laravel5DbBackupCommand.php delete mode 100644 src/Laravel5DbListCommand.php delete mode 100644 src/Laravel5DbRestoreCommand.php delete mode 100644 src/Laravel5ServiceProvider.php delete mode 100644 src/Lumen50ServiceProvider.php delete mode 100644 src/LumenServiceProvider.php diff --git a/README.md b/README.md index 06ba0c2..721850b 100644 --- a/README.md +++ b/README.md @@ -14,18 +14,19 @@ This package pulls in the framework agnostic [Backup Manager](https://github.com - [Scheduling Backups](#scheduling-backups) - [Contribution Guidelines](#contribution-guidelines) - [Maintainers](#maintainers) +- [Changelog](#changelog) - [License](#license) ### Stability Notice It's stable enough, you'll need to understand filesystem permissions. -This package is actively being developed and we would like to get feedback to improve it. [Please feel free to submit feedback.](https://github.com/backup-manager/laravel/issues/new) +This package is being actively developed, and we would like to get feedback to improve it. [Please feel free to submit feedback.](https://github.com/backup-manager/laravel/issues/new) ### Requirements -- PHP 5.5 -- Laravel +- PHP 7.3+ +- Laravel 5.5+ - MySQL support requires `mysqldump` and `mysql` command-line binaries - PostgreSQL support requires `pg_dump` and `psql` command-line binaries - Gzip support requires `gzip` and `gunzip` command-line binaries @@ -59,35 +60,19 @@ composer require league/flysystem-sftp composer require superbalist/flysystem-google-storage ``` -#### Laravel 4 Configuration - -To install into a Laravel 4 project, first do the composer install then add the following class to your config/app.php service providers list. - -```php -BackupManager\Laravel\Laravel4ServiceProvider::class, -``` - -Copy the `vendor/backup-manager/laravel/config/backup-manager.php` file to `app/config/backup-manager.php` and configure it to suit your needs. - #### Laravel 5 Configuration To install into a Laravel project, first do the composer install then add *ONE *of the following classes to your config/app.php service providers list. ```php -// FOR LARAVEL 5.0 ONLY -BackupManager\Laravel\Laravel50ServiceProvider::class, - -// FOR LARAVEL 5.1 - 5.4 -BackupManager\Laravel\Laravel5ServiceProvider::class, - -// FOR LARAVEL 5.5 +// FOR LARAVEL 5.5 + BackupManager\Laravel\Laravel55ServiceProvider::class, ``` Publish the storage configuration file. ```php -php artisan vendor:publish --provider="BackupManager\Laravel\Laravel5ServiceProvider" +php artisan vendor:publish --provider="BackupManager\Laravel\Laravel55ServiceProvider" ``` The Backup Manager will make use of Laravel's database configuration. But, it won't know about any connections that might be tied to other environments, so it can be best to just list multiple connections in the `config/database.php` file. @@ -103,14 +88,6 @@ BACKUP_MANAGER_EXTRA_PARAMS="--column-statistics=0 --max-allowed-packet" To install into a Lumen project, first do the composer install then add the configuration file loader and *ONE* of the following service providers to your `bootstrap/app.php`. ```php -// FOR LUMEN 5.0 ONLY -$app->configure('backup-manager'); -$app->register(BackupManager\Laravel\Lumen50ServiceProvider::class); - -// FOR LUMEN 5.1 - 5.4 -$app->configure('backup-manager'); -$app->register(BackupManager\Laravel\LumenServiceProvider::class); - // FOR LUMEN 5.5 AND ABOVE $app->configure('backup-manager'); $app->register(BackupManager\Laravel\Lumen55ServiceProvider::class); @@ -169,6 +146,16 @@ It's possible to schedule backups using Laravel's scheduler. } ``` +### Changelog + +**2.0** + +_Released on 2020-04-30_ + +Remove support for all Laravel versions below 5.5. All older versions should use the backup-manager `^1.0`. + +Since so many dependencies in Laravel / Symfony have changed it became impossible to support newer versions in the same code-base. Release `^1.0` is stable and is always accepting new stability fixes (we haven't seen anything to fix in a long time). + ### Contribution Guidelines We recommend using the vagrant configuration supplied with this package for development and contribution. Simply install VirtualBox, Vagrant, and Ansible then run `vagrant up` in the root folder. A virtualmachine specifically designed for development of the package will be built and launched for you. diff --git a/composer.json b/composer.json index 41c56a5..4d96f2b 100644 --- a/composer.json +++ b/composer.json @@ -5,21 +5,16 @@ { "name": "Shawn McCool", "email": "shawn@heybigname.com", - "homepage": "http://heybigname.com/" - }, - { - "name": "Mitchell van Wijngaarden", - "email": "mitchell@kooding.nl", - "homepage": "http://heybigname.com/" + "homepage": "https://shawnmc.cool/" } ], "require": { "backup-manager/backup-manager": "^1.0", - "php": ">=5.5.0", - "symfony/process": "^2.0||^3.0||^4.0||^5.0", - "illuminate/support": "^4.0||^5.0||^6.0||^7.0", - "illuminate/container": "^4.0||^5.0||^6.0||^7.0", - "illuminate/console": "^4.0||^5.0||^6.0||^7.0" + "php": "^7.3||^7.4", + "symfony/process": "^3||^4||^5", + "illuminate/support": "^5.5||^6||^7", + "illuminate/container": "^5.5||^6||^7", + "illuminate/console": "^5.5||^6||^7" }, "require-dev": { "mockery/mockery": "dev-master", diff --git a/src/Laravel4Compatibility.php b/src/Laravel4Compatibility.php deleted file mode 100644 index 4d03e68..0000000 --- a/src/Laravel4Compatibility.php +++ /dev/null @@ -1,30 +0,0 @@ -getHelperSet()->get('table'); - } catch (InvalidArgumentException $error) { - // - } finally { - $table = new Table($this->output); - } - - $table->setHeaders($headers); - $table->setRows($rows); - $table->render($this->output); - } -} diff --git a/src/Laravel4DbBackupCommand.php b/src/Laravel4DbBackupCommand.php deleted file mode 100644 index b89b28b..0000000 --- a/src/Laravel4DbBackupCommand.php +++ /dev/null @@ -1,11 +0,0 @@ -package('backup-manager/laravel', 'backup-manager', realpath(app_path("config"))); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() { - $this->registerFilesystemProvider(); - $this->registerDatabaseProvider(); - $this->registerCompressorProvider(); - $this->registerShellProcessor(); - $this->registerArtisanCommands(); - } - - /** - * Register the filesystem provider. - * - * @return void - */ - private function registerFilesystemProvider() { - $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { - $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); - $provider->add(new Filesystems\Awss3Filesystem); - $provider->add(new Filesystems\GcsFilesystem); - $provider->add(new Filesystems\DropboxFilesystem); - $provider->add(new Filesystems\DropboxV2Filesystem); - $provider->add(new Filesystems\FtpFilesystem); - $provider->add(new Filesystems\LocalFilesystem); - $provider->add(new Filesystems\RackspaceFilesystem); - $provider->add(new Filesystems\SftpFilesystem); - return $provider; - }); - } - - /** - * Register the database provider. - * - * @return void - */ - private function registerDatabaseProvider() { - $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) { - $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections'])); - $provider->add(new Databases\MysqlDatabase); - $provider->add(new Databases\PostgresqlDatabase); - return $provider; - }); - } - - /** - * Register the compressor provider. - * - * @return void - */ - private function registerCompressorProvider() { - $this->app->bind(\BackupManager\Compressors\CompressorProvider::class, function () { - $provider = new Compressors\CompressorProvider; - $provider->add(new Compressors\GzipCompressor); - $provider->add(new Compressors\NullCompressor); - return $provider; - }); - } - - /** - * Register the filesystem provider. - * - * @return void - */ - private function registerShellProcessor() { - $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { - return new ShellProcessor(new Process('', null, null, null, null)); - }); - } - - /** - * Register the artisan commands. - * - * @return void - */ - private function registerArtisanCommands() { - $this->commands([ - \BackupManager\Laravel\Laravel4DbBackupCommand::class, - \BackupManager\Laravel\Laravel4DbRestoreCommand::class, - \BackupManager\Laravel\Laravel4DbListCommand::class - ]); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() { - return [ - \BackupManager\Filesystems\FilesystemProvider::class, - \BackupManager\Databases\DatabaseProvider::class, - \BackupManager\ShellProcessing\ShellProcessor::class, - ]; - } -} diff --git a/src/Laravel50Compatibility.php b/src/Laravel50Compatibility.php deleted file mode 100644 index 69de9ed..0000000 --- a/src/Laravel50Compatibility.php +++ /dev/null @@ -1,30 +0,0 @@ -getHelperSet()->get('table'); - } catch (InvalidArgumentException $error) { - // - } finally { - $table = new Table($this->output); - } - - $table->setHeaders($headers); - $table->setRows($rows); - $table->render($this->output); - } -} diff --git a/src/Laravel50DbBackupCommand.php b/src/Laravel50DbBackupCommand.php deleted file mode 100644 index 6c5ed07..0000000 --- a/src/Laravel50DbBackupCommand.php +++ /dev/null @@ -1,11 +0,0 @@ -publishes([$configPath => config_path('backup-manager.php')], 'config'); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() { - $configPath = __DIR__ . '/../config/backup-manager.php'; - $this->mergeConfigFrom($configPath, 'backup-manager'); - $this->registerFilesystemProvider(); - $this->registerDatabaseProvider(); - $this->registerCompressorProvider(); - $this->registerShellProcessor(); - $this->registerArtisanCommands(); - } - - /** - * Register the filesystem provider. - * - * @return void - */ - private function registerFilesystemProvider() { - $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { - $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); - $provider->add(new Filesystems\Awss3Filesystem); - $provider->add(new Filesystems\DropboxFilesystem); - $provider->add(new Filesystems\DropboxV2Filesystem); - $provider->add(new Filesystems\FtpFilesystem); - $provider->add(new Filesystems\LocalFilesystem); - $provider->add(new Filesystems\RackspaceFilesystem); - $provider->add(new Filesystems\SftpFilesystem); - return $provider; - }); - } - - /** - * Register the database provider. - * - * @return void - */ - private function registerDatabaseProvider() { - $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) { - $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections'])); - $provider->add(new Databases\MysqlDatabase); - $provider->add(new Databases\PostgresqlDatabase); - return $provider; - }); - } - - /** - * Register the compressor provider. - * - * @return void - */ - private function registerCompressorProvider() { - $this->app->bind(\BackupManager\Compressors\CompressorProvider::class, function () { - $provider = new Compressors\CompressorProvider; - $provider->add(new Compressors\GzipCompressor); - $provider->add(new Compressors\NullCompressor); - return $provider; - }); - } - - /** - * Register the filesystem provider. - * - * @return void - */ - private function registerShellProcessor() { - $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { - return new ShellProcessor(new Process('')); - }); - } - - /** - * Register the artisan commands. - * - * @return void - */ - private function registerArtisanCommands() { - $this->commands([ - \BackupManager\Laravel\Laravel50DbBackupCommand::class, - \BackupManager\Laravel\Laravel50DbRestoreCommand::class, - \BackupManager\Laravel\Laravel50DbListCommand::class, - ]); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() { - return [ - \BackupManager\Filesystems\FilesystemProvider::class, - \BackupManager\Databases\DatabaseProvider::class, - \BackupManager\ShellProcessing\ShellProcessor::class, - ]; - } -} diff --git a/src/Laravel51Compatibility.php b/src/Laravel51Compatibility.php deleted file mode 100644 index ae0cccc..0000000 --- a/src/Laravel51Compatibility.php +++ /dev/null @@ -1,30 +0,0 @@ -getHelperSet()->get('table'); - } catch (InvalidArgumentException $error) { - // - } finally { - $table = new Table($this->output); - } - - $table->setHeaders($headers); - $table->setRows($rows); - $table->render($this->output); - } -} diff --git a/src/Laravel5DbBackupCommand.php b/src/Laravel5DbBackupCommand.php deleted file mode 100644 index eb73cb6..0000000 --- a/src/Laravel5DbBackupCommand.php +++ /dev/null @@ -1,11 +0,0 @@ -publishes([$configPath => config_path('backup-manager.php')], 'config'); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() { - $configPath = __DIR__ . '/../config/backup-manager.php'; - $this->mergeConfigFrom($configPath, 'backup-manager'); - $this->registerFilesystemProvider(); - $this->registerDatabaseProvider(); - $this->registerCompressorProvider(); - $this->registerShellProcessor(); - $this->registerArtisanCommands(); - } - - /** - * Register the filesystem provider. - * - * @return void - */ - private function registerFilesystemProvider() { - $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { - $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); - $provider->add(new Filesystems\Awss3Filesystem); - $provider->add(new Filesystems\GcsFilesystem); - $provider->add(new Filesystems\DropboxFilesystem); - $provider->add(new Filesystems\DropboxV2Filesystem); - $provider->add(new Filesystems\FtpFilesystem); - $provider->add(new Filesystems\LocalFilesystem); - $provider->add(new Filesystems\RackspaceFilesystem); - $provider->add(new Filesystems\SftpFilesystem); - return $provider; - }); - } - - /** - * Register the database provider. - * - * @return void - */ - private function registerDatabaseProvider() { - $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) { - $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections'])); - $provider->add(new Databases\MysqlDatabase); - $provider->add(new Databases\PostgresqlDatabase); - return $provider; - }); - } - - /** - * Register the compressor provider. - * - * @return void - */ - private function registerCompressorProvider() { - $this->app->bind(\BackupManager\Compressors\CompressorProvider::class, function () { - $provider = new Compressors\CompressorProvider; - $provider->add(new Compressors\GzipCompressor); - $provider->add(new Compressors\NullCompressor); - return $provider; - }); - } - - /** - * Register the filesystem provider. - * - * @return void - */ - private function registerShellProcessor() { - $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { - return new ShellProcessor(new Process('', null, null, null, null)); - }); - } - - /** - * Register the artisan commands. - * - * @return void - */ - private function registerArtisanCommands() { - $this->commands([ - \BackupManager\Laravel\Laravel5DbBackupCommand::class, - \BackupManager\Laravel\Laravel5DbRestoreCommand::class, - \BackupManager\Laravel\Laravel5DbListCommand::class, - ]); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() { - return [ - \BackupManager\Filesystems\FilesystemProvider::class, - \BackupManager\Databases\DatabaseProvider::class, - \BackupManager\ShellProcessing\ShellProcessor::class, - ]; - } -} diff --git a/src/Lumen50ServiceProvider.php b/src/Lumen50ServiceProvider.php deleted file mode 100644 index 6c878ca..0000000 --- a/src/Lumen50ServiceProvider.php +++ /dev/null @@ -1,118 +0,0 @@ -mergeConfigFrom($configPath, 'backup-manager'); - $this->registerFilesystemProvider(); - $this->registerDatabaseProvider(); - $this->registerCompressorProvider(); - $this->registerShellProcessor(); - $this->registerArtisanCommands(); - } - - /** - * Register the filesystem provider. - * - * @return void - */ - private function registerFilesystemProvider() { - $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { - $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); - $provider->add(new Filesystems\Awss3Filesystem); - $provider->add(new Filesystems\DropboxFilesystem); - $provider->add(new Filesystems\DropboxV2Filesystem); - $provider->add(new Filesystems\FtpFilesystem); - $provider->add(new Filesystems\LocalFilesystem); - $provider->add(new Filesystems\RackspaceFilesystem); - $provider->add(new Filesystems\SftpFilesystem); - return $provider; - }); - } - - /** - * Register the database provider. - * - * @return void - */ - private function registerDatabaseProvider() { - $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) { - $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections'])); - $provider->add(new Databases\MysqlDatabase); - $provider->add(new Databases\PostgresqlDatabase); - return $provider; - }); - } - - /** - * Register the compressor provider. - * - * @return void - */ - private function registerCompressorProvider() { - $this->app->bind(\BackupManager\Compressors\CompressorProvider::class, function () { - $provider = new Compressors\CompressorProvider; - $provider->add(new Compressors\GzipCompressor); - $provider->add(new Compressors\NullCompressor); - return $provider; - }); - } - - /** - * Register the filesystem provider. - * - * @return void - */ - private function registerShellProcessor() { - $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { - return new ShellProcessor(new Process('')); - }); - } - - /** - * Register the artisan commands. - * - * @return void - */ - private function registerArtisanCommands() { - $this->commands([ - \BackupManager\Laravel\Laravel50DbBackupCommand::class, - \BackupManager\Laravel\Laravel50DbRestoreCommand::class, - \BackupManager\Laravel\Laravel50DbListCommand::class, - ]); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() { - return [ - \BackupManager\Filesystems\FilesystemProvider::class, - \BackupManager\Databases\DatabaseProvider::class, - \BackupManager\ShellProcessing\ShellProcessor::class, - ]; - } -} diff --git a/src/LumenServiceProvider.php b/src/LumenServiceProvider.php deleted file mode 100644 index b971f74..0000000 --- a/src/LumenServiceProvider.php +++ /dev/null @@ -1,119 +0,0 @@ -mergeConfigFrom($configPath, 'backup-manager'); - $this->registerFilesystemProvider(); - $this->registerDatabaseProvider(); - $this->registerCompressorProvider(); - $this->registerShellProcessor(); - $this->registerArtisanCommands(); - } - - /** - * Register the filesystem provider. - * - * @return void - */ - private function registerFilesystemProvider() { - $this->app->bind(\BackupManager\Filesystems\FilesystemProvider::class, function ($app) { - $provider = new Filesystems\FilesystemProvider(new Config($app['config']['backup-manager'])); - $provider->add(new Filesystems\Awss3Filesystem); - $provider->add(new Filesystems\GcsFilesystem); - $provider->add(new Filesystems\DropboxFilesystem); - $provider->add(new Filesystems\DropboxV2Filesystem); - $provider->add(new Filesystems\FtpFilesystem); - $provider->add(new Filesystems\LocalFilesystem); - $provider->add(new Filesystems\RackspaceFilesystem); - $provider->add(new Filesystems\SftpFilesystem); - return $provider; - }); - } - - /** - * Register the database provider. - * - * @return void - */ - private function registerDatabaseProvider() { - $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) { - $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections'])); - $provider->add(new Databases\MysqlDatabase); - $provider->add(new Databases\PostgresqlDatabase); - return $provider; - }); - } - - /** - * Register the compressor provider. - * - * @return void - */ - private function registerCompressorProvider() { - $this->app->bind(\BackupManager\Compressors\CompressorProvider::class, function () { - $provider = new Compressors\CompressorProvider; - $provider->add(new Compressors\GzipCompressor); - $provider->add(new Compressors\NullCompressor); - return $provider; - }); - } - - /** - * Register the filesystem provider. - * - * @return void - */ - private function registerShellProcessor() { - $this->app->bind(\BackupManager\ShellProcessing\ShellProcessor::class, function () { - return new ShellProcessor(new Process('', null, null, null, null)); - }); - } - - /** - * Register the artisan commands. - * - * @return void - */ - private function registerArtisanCommands() { - $this->commands([ - \BackupManager\Laravel\Laravel5DbBackupCommand::class, - \BackupManager\Laravel\Laravel5DbRestoreCommand::class, - \BackupManager\Laravel\Laravel5DbListCommand::class, - ]); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() { - return [ - \BackupManager\Filesystems\FilesystemProvider::class, - \BackupManager\Databases\DatabaseProvider::class, - \BackupManager\ShellProcessing\ShellProcessor::class, - ]; - } -} From 960d8443583b3e2a7dc5cd77858106a7e44e6d9a Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Thu, 30 Apr 2020 19:11:45 +0200 Subject: [PATCH 67/69] link to open source heroes --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 721850b..72078ae 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ This package pulls in the framework agnostic [Backup Manager](https://github.com - [Scheduling Backups](#scheduling-backups) - [Contribution Guidelines](#contribution-guidelines) - [Maintainers](#maintainers) -- [Changelog](#changelog) - [License](#license) +- [Changelog](#changelog) ### Stability Notice @@ -146,16 +146,6 @@ It's possible to schedule backups using Laravel's scheduler. } ``` -### Changelog - -**2.0** - -_Released on 2020-04-30_ - -Remove support for all Laravel versions below 5.5. All older versions should use the backup-manager `^1.0`. - -Since so many dependencies in Laravel / Symfony have changed it became impossible to support newer versions in the same code-base. Release `^1.0` is stable and is always accepting new stability fixes (we haven't seen anything to fix in a long time). - ### Contribution Guidelines We recommend using the vagrant configuration supplied with this package for development and contribution. Simply install VirtualBox, Vagrant, and Ansible then run `vagrant up` in the root folder. A virtualmachine specifically designed for development of the package will be built and launched for you. @@ -171,8 +161,18 @@ When contributing please consider the following guidelines: ### Maintainers -This package is maintained by [Shawn McCool](http://shawnmc.cool) and [Mitchell van Wijngaarden](http://kooding.nl). +This package is maintained by [Shawn McCool](http://shawnmc.cool) and [open-source heroes](https://github.com/backup-manager/laravel/pulls?q=is%3Apr+is%3Aclosed). ### License This package is licensed under the [MIT license](https://github.com/backup-manager/laravel/blob/master/LICENSE). + +### Changelog + +**2.0** + +_Released on 2020-04-30_ + +Remove support for all Laravel versions below 5.5. All older versions should use the backup-manager `^1.0`. + +Since so many dependencies in Laravel / Symfony have changed it became impossible to support newer versions in the same code-base. Release `^1.0` is stable and is always accepting new stability fixes (we haven't seen anything to fix in a long time). From 888929ddc22f079fcf9572c66097dfcb006825f4 Mon Sep 17 00:00:00 2001 From: Alex Fedorko Date: Fri, 29 May 2020 22:14:23 +0300 Subject: [PATCH 68/69] update backup-manager version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4d96f2b..c23a88e 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ } ], "require": { - "backup-manager/backup-manager": "^1.0", + "backup-manager/backup-manager": "^2.0", "php": "^7.3||^7.4", "symfony/process": "^3||^4||^5", "illuminate/support": "^5.5||^6||^7", From 380ad399a027171e305cd7ccfb3d8dc5d4458f93 Mon Sep 17 00:00:00 2001 From: Alex Fedorko Date: Fri, 29 May 2020 22:29:35 +0300 Subject: [PATCH 69/69] update backup-manager version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c23a88e..89f95b3 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ } ], "require": { - "backup-manager/backup-manager": "^2.0", + "backup-manager/backup-manager": "^3.0", "php": "^7.3||^7.4", "symfony/process": "^3||^4||^5", "illuminate/support": "^5.5||^6||^7",