diff --git a/README.md b/README.md index 3540959..312fc5c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ An admin interface for [spatie/laravel-backup](https://github.com/spatie/laravel > ### Security updates and breaking changes > Please **[subscribe to the Backpack Newsletter](http://backpackforlaravel.com/newsletter)** so you can find out about any security updates, breaking changes or major features. We send an email 2 times/year, max. -![Backpack\BackupManager screenshot](https://user-images.githubusercontent.com/1032474/150080754-97dca93f-3cac-452b-9bcf-cc51becd3055.png) +![Backpack\BackupManager screenshot](https://user-images.githubusercontent.com/1032474/161931994-dc044bb2-a459-4863-9262-ed91f3e5e35b.gif) ## Install @@ -25,41 +25,13 @@ An admin interface for [spatie/laravel-backup](https://github.com/spatie/laravel # Install the package composer require backpack/backupmanager -# Add a sidebar_content item for it -php artisan backpack:add-sidebar-content "" -``` - -You will notice that two configuration files are created. You should check [spatie documentations on how to configura your backup system](https://spatie.be/docs/laravel-backup/v8/installation-and-setup) in `config/backup.php` - -As far as `config/backpack/backupmanager.php` it configures how the `Backup` button works: `--only-files, --only-db` etc. +# Publish the backup and backupmanager configs and lang files: +php artisan vendor:publish --provider="Backpack\BackupManager\BackupManagerServiceProvider" --tag=backup-config --tag=lang -3) [optional] You can add backup flags for when the backup process is run from the user interface. In your `config/backup.php` under the `backup` key you can add the `backpack_flags` array below: - -```php - 'backup' => [ - - /* -------------------------------------- - * Backpack\BackupManager Command Flags - * -------------------------------------- - * These flags will be attached every time a backup is triggered - * by Backpack\BackupManager. By default only notifications are disabled. - * - * https://docs.spatie.be/laravel-backup/v4/taking-backups/overview - * --only-to-disk=name-of-your-disk - * --only-db - * --only-files - * --disable-notifications - */ - 'backpack_flags' => [ - '--disable-notifications'=> true, - ], - - // ... - ], +# [optional] Add a sidebar_content item for it +php artisan backpack:add-sidebar-content "" ``` -4) [optional] Modify your backup options in ```config/backup.php``` (which is `spatie/laravel-backup`'s config file), then run ```php artisan backup:run``` to make sure it's still working. - 5) [optional] Instruct Laravel to run the backups automatically in your console kernel: ```php @@ -67,8 +39,9 @@ As far as `config/backpack/backupmanager.php` it configures how the `Backup` but protected function schedule(Schedule $schedule) { - $schedule->command('backup:clean')->daily()->at('04:00'); - $schedule->command('backup:run')->daily()->at('05:00'); + // if you are not using notifications you should add the `--disable-notifications` flag to this commands + $schedule->command('backup:clean')->daily()->at('04:00'); + $schedule->command('backup:run')->daily()->at('05:00'); } ``` @@ -76,73 +49,59 @@ protected function schedule(Schedule $schedule) If the "unknown error" yellow bubble is thrown and you see the "_Backup failed because The dump process failed with exitcode 127 : Command not found._" error in the log file, either mysqldump / pg_dump is not installed or you need to specify its location. -You can do that in your `config/database.php` file, where you define your database credentials, by adding the dump variables. Example for Mac OS X's MAMP: +You can do that in your `config/database.php` file, where you define your database credentials, by adding the dump variables. Here's an example: ```php 'mysql' => [ - 'driver' => 'mysql', - 'host' => env('DB_HOST', 'localhost'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - 'strict' => false, - 'engine' => null, - 'dump' => [ - - 'dump_binary_path' => '/path/to/directory/', // only the path, without `mysqldump` or `pg_dump` - // 'dump_binary_path' => '/Applications/MAMP/Library/bin/', // works for MAMP on Mac OS - // 'dump_binary_path' => '/opt/homebrew/bin/', // works for Laravel Valet on Mac OS - 'use_single_transaction', - 'timeout' => 60 * 5, // 5 minute timeout - // 'exclude_tables' => ['table1', 'table2'], - // 'add_extra_option' => '--optionname=optionvalue', - ] - ], + 'driver' => 'mysql', + 'host' => env('DB_HOST', 'localhost'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'prefix' => '', + 'strict' => false, + 'engine' => null, + 'dump' => [ + + 'dump_binary_path' => '/path/to/directory/', // only the path, without `mysqldump` or `pg_dump` + // 'dump_binary_path' => '/Applications/MAMP/Library/bin/', // works for MAMP on Mac OS + // 'dump_binary_path' => '/opt/homebrew/bin/', // works for Laravel Valet on Mac OS + 'use_single_transaction', + 'timeout' => 60 * 5, // 5 minute timeout + // 'exclude_tables' => ['table1', 'table2'], + // 'add_extra_option' => '--optionname=optionvalue', + ] +], ``` ## Usage -Point and click, baby. Point and click. +This should be a point-and-click interface where you can create and download backups at any time. Try at **your-project-domain/admin/backup** +## Configuration & Troubleshooting -## Upgrading from 2.x to 3.x - -Change your required version to ```"backpack/backupmanager": "^3.0",``` and run ```composer update```. There are no breaking changes just icons that are show using ```la la-icon``` instead of ```fa fa-icon```. - - -## Upgrading from 1.2.x to 1.3.x - -1) change your required version to ```"backpack/backupmanager": "^1.3",``` and run ```composer update```; -2) delete the old config file (too many changes, including namechange): ```rm config/laravel-backup.php``` -3) republish the config files: ```php artisan vendor:publish --provider="Backpack\BackupManager\BackupManagerServiceProvider"``` -4) change your db configuration in ```config/database.php``` to use the new dump configuration (all options in one array; the example below is for MAMP on MacOS): - -``` - 'dump' => [ - 'dump_binary_path' => '/Applications/MAMP/Library/bin/', // only the path, so without `mysqldump` or `pg_dump` - 'use_single_transaction', - 'timeout' => 60 * 5, // 5 minute timeout - // 'exclude_tables' => ['table1', 'table2'], - // 'add_extra_option' => '--optionname=optionvalue', - ] -``` -5) Create a backup in the interface to test it works. If it doesn't try ```php artisan backup:run``` to see what the problem is. - +For additional configuration (eg. notifications): +- publish the spatie backup file `php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider" --tag="backup-config"` +- see the [spatie/laravel-backup documentation](https://spatie.be/docs/laravel-backup/v8/installation-and-setup) on how to configure your backup system in `config/backup.php`; **it is higly recommended that you at least [configure the notifications](https://spatie.be/docs/laravel-backup/v8/sending-notifications/overview)**; +- see `config/backpack/backupmanager.php` for configurating how the backup is run from the interface; by default, it does `backup:run --disable-notifications`, but after you've configured notifications, you can remove that flag (or add others); -## Upgrading from 1.1.x to 1.2.x +**[TIP]** When you modify your options in `config/backup.php` or `config/backpack/backupmanager.php`, please run manually `php artisan backup:run` to make sure it's still working after your changes. **NOTE**: `php artisan optimize:clear` and/or `php artisan config:clear` might be needed before the `backup:run` command. -1) change your required version to ```"backpack/backupmanager": "^1.2",```; -2) the only breaking change is that the ```config/database.php``` dump variables are now inside an array. Please see the step 8 above, copy-paste the ```dump``` array from there and customize; +## Upgrading +Please see the [upgrade guides](UPGRADE_GUIDES.md) to get: +- from v3 to v4 (new!) +- from v2 to v3 +- from 1.2.x to 1.3.x +- from 1.1.x to 1.2.x ## Change log -Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. +Please see the [releases page](https://github.com/Laravel-Backpack/BackupManager/releases/) for more information what has changed recently. ## Testing diff --git a/UPGRADE_GUIDES.md b/UPGRADE_GUIDES.md new file mode 100644 index 0000000..29c86a6 --- /dev/null +++ b/UPGRADE_GUIDES.md @@ -0,0 +1,73 @@ +# Upgrade Guides + +## Upgrading from 3.x to 4.x + +Change your required version to `"backpack/backupmanager": "^4.0"` and run `composer update backpack/backupmanager`. + +We removed the overrides of spatie config from our package publishing process, from now on you can do the regular spatie backup configuration in `config/backup.php` and the customized backpack configuration in `config/backpack/backupmanager`. + +**1)** Publish the new config file `php artisan vendor:publish --provider="Backpack\BackupManager\BackupManagerServiceProvider" --tag="backup-config"`. This will generate the `config/backpack/backupmanager.php` file. By default backpack uses `--disable-notifications` flag, remove it if you are using notifications. + +**2)** If you have configured `backpack_flags` in `config/backup` you should now move them to the new config, under the key: `artisan_command_on_button_click`. + +```php +// This command will be run when user click on the "Create a new backup" button +// You can add flags to this like --only-db --only-files --only-to-disk=name-of-disk --disable-notifications +// Details here: https://spatie.be/docs/laravel-backup/v8/taking-backups/overview +'artisan_command_on_button_click' => 'backup:run --disable-notifications', +``` + +**3)** If you didn't do anymore configs you can now safely remove the `config/backup.php` file and there is no need to re-publish the spatie config, **jump to step 5**. + +**4)** If you are customizing other options in `config/backup.php` file make sure that your changes are compatible with the new config (it should be), otherwise save your config file in some other place, force publish the v8 spatie configuration file with `php artisan vendor:publish --force --provider="Spatie\Backup\BackupServiceProvider" --tag="backup-config"` and then re-configure what you need. + +**5)** You may need to clear the cache with `php artisan optimize:clear` and/or `php artisan config:clear`. + +**6)** Manually run from console the `backup:run` command to make sure it's working, use `backup:run --disable-notifications` if you are not using notifications. + +**7)** If you are **scheduling your backup jobs** make sure to also use the apropriate synthax in the commands. In previous backup versions the notification exceptions would **not be reported** and your scripts would run fine even if an exception was thrown. Now **they report**, so to avoid the exceptions halting your scripts in the notification part, **you need to explicitly tell the backup script that you don't want notifications** if you didn't configure them: + +```php +// app/Console/Kernel.php + +protected function schedule(Schedule $schedule) +{ + // this would work previously even if you didn't configured notifications, + // it would throw an exception but it was not reported, so script is not halted. + $schedule->command('backup:clean')->daily()->at('04:00'); + + // now if you don't use notifications you should explicitly tell that to backup + // otherwise the same exception will be thrown, but this time reported, + // halting the script execution. + $schedule->command('backup:clean --disable-notifications')->daily()->at('04:00'); +} +``` + +## Upgrading from 2.x to 3.x + +Change your required version to ```"backpack/backupmanager": "^3.0",``` and run ```composer update```. There are no breaking changes just icons that are show using ```la la-icon``` instead of ```fa fa-icon```. + + +## Upgrading from 1.2.x to 1.3.x + +1) change your required version to ```"backpack/backupmanager": "^1.3",``` and run ```composer update```; +2) delete the old config file (too many changes, including namechange): ```rm config/laravel-backup.php``` +3) republish the config files: ```php artisan vendor:publish --provider="Backpack\BackupManager\BackupManagerServiceProvider"``` +4) change your db configuration in ```config/database.php``` to use the new dump configuration (all options in one array; the example below is for MAMP on MacOS): + +```php +'dump' => [ + 'dump_binary_path' => '/Applications/MAMP/Library/bin/', // only the path, so without `mysqldump` or `pg_dump` + 'use_single_transaction', + 'timeout' => 60 * 5, // 5 minute timeout + // 'exclude_tables' => ['table1', 'table2'], + // 'add_extra_option' => '--optionname=optionvalue', +] +``` +5) Create a backup in the interface to test it works. If it doesn't try ```php artisan backup:run``` to see what the problem is. + + +## Upgrading from 1.1.x to 1.2.x + +1) change your required version to ```"backpack/backupmanager": "^1.2",```; +2) the only breaking change is that the ```config/database.php``` dump variables are now inside an array. Please see the step 8 above, copy-paste the ```dump``` array from there and customize; diff --git a/src/BackupManagerServiceProvider.php b/src/BackupManagerServiceProvider.php index 2576ff3..1fdc601 100644 --- a/src/BackupManagerServiceProvider.php +++ b/src/BackupManagerServiceProvider.php @@ -38,8 +38,11 @@ public function boot() // - then the stock views that come with the package, in case a published view might be missing $this->loadViewsFrom(realpath(__DIR__.'/resources/views'), 'backupmanager'); + // publish config file + $this->publishes([__DIR__.'/config/backupmanager.php' => config_path('backpack/backupmanager.php')], 'backup-config'); + // publish lang files - $this->publishes([__DIR__.'/resources/lang' => resource_path('lang/vendor/backpack')], 'lang'); + $this->publishes([__DIR__.'/resources/lang' => app()->langPath().'/vendor/backpack'], 'lang'); // publish the views $this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/backpack/backupmanager')], 'views'); } diff --git a/src/app/Http/Controllers/BackupController.php b/src/app/Http/Controllers/BackupController.php index cdd3335..2afbdcb 100644 --- a/src/app/Http/Controllers/BackupController.php +++ b/src/app/Http/Controllers/BackupController.php @@ -3,11 +3,12 @@ namespace Backpack\BackupManager\app\Http\Controllers; use Artisan; +use Carbon\Carbon; use Exception; use Illuminate\Routing\Controller; +use League\Flysystem\Local\LocalFilesystemAdapter; use Log; use Request; -use Response; use Storage; class BackupController extends Controller @@ -15,27 +16,32 @@ class BackupController extends Controller public function index() { if (!count(config('backup.backup.destination.disks'))) { - dd(trans('backpack::backup.no_disks_configured')); + abort(500, trans('backpack::backup.no_disks_configured')); } $this->data['backups'] = []; - foreach (config('backup.backup.destination.disks') as $disk_name) { - $disk = Storage::disk($disk_name); - $can_download = config("filesystems.disks.$disk_name.driver") == 'local'; + foreach (config('backup.backup.destination.disks') as $diskName) { + $disk = Storage::disk($diskName); $files = $disk->allFiles(); // make an array of backup files, with their filesize and creation date - foreach ($files as $k => $f) { + foreach ($files as $file) { + // remove diskname from filename + $fileName = str_replace('backups/', '', $file); + $downloadLink = route('backup.download', ['file_name' => $fileName, 'disk' => $diskName]); + $deleteLink = route('backup.destroy', ['file_name' => $fileName, 'disk' => $diskName]); + // only take the zip files into account - if (substr($f, -4) == '.zip' && $disk->exists($f)) { - $this->data['backups'][] = [ - 'file_path' => $f, - 'file_name' => str_replace('backups/', '', $f), - 'file_size' => $disk->size($f), - 'last_modified' => $disk->lastModified($f), - 'disk' => $disk_name, - 'download' => $can_download ? true : false, + if (substr($file, -4) == '.zip' && $disk->exists($file)) { + $this->data['backups'][] = (object) [ + 'filePath' => $file, + 'fileName' => $fileName, + 'fileSize' => round((int) $disk->size($file) / 1048576, 2), + 'lastModified' => Carbon::createFromTimeStamp($disk->lastModified($file))->formatLocalized('%d %B %Y, %H:%M'), + 'diskName' => $diskName, + 'downloadLink' => is_a($disk->getAdapter(), LocalFilesystemAdapter::class, true) ? $downloadLink : null, + 'deleteLink' => $deleteLink, ]; } } @@ -43,19 +49,15 @@ public function index() // reverse the backups, so the newest one would be on top $this->data['backups'] = array_reverse($this->data['backups']); - $this->data['title'] = 'Backups'; + $this->data['title'] = trans('backupmanager::backups'); return view('backupmanager::backup', $this->data); } public function create() { - $message = 'success'; - $command = config('backpack.backupmanager.artisan_command_on_button_click') ?? 'backup:run'; - $flags = $command === 'backup:run' ? config('backup.backpack_flags', []) : []; - try { foreach (config('backpack.backupmanager.ini_settings', []) as $setting => $value) { ini_set($setting, $value); @@ -63,24 +65,23 @@ public function create() Log::info('Backpack\BackupManager -- Called backup:run from admin interface'); - Artisan::call($command, $flags); + Artisan::call($command); $output = Artisan::output(); if (strpos($output, 'Backup failed because')) { preg_match('/Backup failed because(.*?)$/ms', $output, $match); - $message = "Backpack\BackupManager -- backup process failed because "; - $message .= isset($match[1]) ? $match[1] : ''; + $message = "Backpack\BackupManager -- backup process failed because ".($match[1] ?? ''); Log::error($message.PHP_EOL.$output); - } else { - Log::info("Backpack\BackupManager -- backup process has started"); + + return response($message, 500); } } catch (Exception $e) { Log::error($e); - return Response::make($e->getMessage(), 500); + return response($e->getMessage(), 500); } - return $message; + return true; } /** @@ -88,24 +89,15 @@ public function create() */ public function download() { - $disk_name = Request::input('disk'); - $disk = Storage::disk($disk_name); - $file_name = Request::input('file_name'); - $can_download = config("filesystems.disks.$disk_name.driver") == 'local'; - - if ($can_download) { - if ($disk->exists($file_name)) { - if (method_exists($disk->getAdapter(), 'getPathPrefix')) { - $storage_path = $disk->getAdapter()->getPathPrefix(); - - return response()->download($storage_path.$file_name); - } else { - return $disk->download($file_name); - } - } else { - abort(404, trans('backpack::backup.backup_doesnt_exist')); - } - } else { + $diskName = Request::input('disk'); + $fileName = Request::input('file_name'); + $disk = Storage::disk($diskName); + + if (!$this->isBackupDisk($diskName)) { + abort(500, trans('backpack::backup.unknown_disk')); + } + + if (!is_a($disk->getAdapter(), LocalFilesystemAdapter::class, true)) { abort(404, trans('backpack::backup.only_local_downloads_supported')); } @@ -119,22 +111,33 @@ public function download() /** * Deletes a backup file. */ - public function delete($file_name) + public function delete() { $diskName = Request::input('disk'); + $fileName = Request::input('file_name'); - if (!in_array($diskName, config('backup.backup.destination.disks'))) { - abort(500, trans('backpack::backup.unknown_disk')); + if (!$this->isBackupDisk($diskName)) { + return response(trans('backpack::backup.unknown_disk'), 500); } $disk = Storage::disk($diskName); - if ($disk->exists($file_name)) { - $disk->delete($file_name); - - return 'success'; - } else { - abort(404, trans('backpack::backup.backup_doesnt_exist')); + if (!$disk->exists($fileName)) { + return response(trans('backpack::backup.backup_doesnt_exist'), 404); } + + return $disk->delete($fileName); + } + + /** + * Check if disk is a backup disk. + * + * @param string $diskName + * + * @return bool + */ + private function isBackupDisk(string $diskName) + { + return in_array($diskName, config('backup.backup.destination.disks')); } } diff --git a/src/config/backupmanager.php b/src/config/backupmanager.php index 5f17188..8474b11 100644 --- a/src/config/backupmanager.php +++ b/src/config/backupmanager.php @@ -4,7 +4,7 @@ // What is being run when the admin clicks on the "Create a new backup" button // You can add flags to this like --only-db --only-files --only-to-disk=name-of-disk // Details here: https://spatie.be/docs/laravel-backup/v8/taking-backups/overview - 'artisan_command_on_button_click' => 'backup:run', + 'artisan_command_on_button_click' => 'backup:run --disable-notifications', // here you can configure your php settings that will apply before starting the backup operation // one of the things that Backpack does by default is increasing the `max_execution_time` for diff --git a/src/resources/lang/en/backup.php b/src/resources/lang/en/backup.php index 36ee975..03b89fe 100644 --- a/src/resources/lang/en/backup.php +++ b/src/resources/lang/en/backup.php @@ -29,7 +29,6 @@ 'delete_cancel_title' => "It's ok", 'delete_cancel_message' => 'The backup file has NOT been deleted.', 'create_confirmation_title' => 'Backup process started.', - 'create_confirmation_message' => 'Refresh the page for it to show in the list.', 'create_error_title' => 'Backup error', 'create_error_message' => 'The backup file could NOT be created.', 'create_warning_title' => 'Unknown error', @@ -39,6 +38,8 @@ 'backup_doesnt_exist' => "The backup file doesn't exist.", 'only_local_downloads_supported' => 'Only downloads from the Local filesystem are supported.', 'unknown_disk' => 'Unknown disk.', - 'create_started_message' => 'Please wait a few minutes for it to complete, then refresh the page.', + 'create_started_message' => 'Please wait a few minutes for it to complete.', 'create_completed_title' => 'Your backup is complete.', + 'download_confirmation_title' => 'Download process started.', + 'download_error_title' => 'Download error', ]; diff --git a/src/resources/lang/pt/backup.php b/src/resources/lang/pt/backup.php index bf51b46..77c69b4 100644 --- a/src/resources/lang/pt/backup.php +++ b/src/resources/lang/pt/backup.php @@ -28,17 +28,18 @@ 'delete_error_message' => 'O backup NÃO foi apagado.', 'delete_cancel_title' => 'Está tudo bem!', 'delete_cancel_message' => 'O backup NÃO foi apagado.', - 'create_confirmation_title' => 'Backup concluído', - 'create_confirmation_message' => 'Recarregue a página para ver o backup na lista.', - 'create_error_title' => 'Erro ao fazer backup', + 'create_confirmation_title' => 'Backup iniciado.', + 'create_error_title' => 'Erro ao fazer o backup', 'create_error_message' => 'O backup não foi criado.', 'create_warning_title' => 'Erro desconhecido', 'create_warning_message' => 'O backup pode NÃO ter sido criado. Por favor verifique o registo para obter mais detalhes.', 'location' => 'Localização', - 'no_disks_configured' => 'Nenhum foi configurado nenhum disco de backups em config/backup.php', + 'no_disks_configured' => 'Não foi configurado nenhum disco de backups em config/backup.php', 'backup_doesnt_exist' => 'O backup não existe', 'only_local_downloads_supported' => 'Apenas são permitidas transferências do sistema de ficheiros local.', 'unknown_disk' => 'Disco de backup desconhecido.', - 'create_started_message' => 'Aguarde uns minutos pela conclusão do backup, depois recarregue a página.', - 'create_completed_title' => 'O backup está completo.', + 'create_started_message' => 'Por favor aguarde alguns minutos pela conclusão do backup.', + 'create_completed_title' => 'O backup está concluído.', + 'download_confirmation_title' => 'Download iniciado.', + 'download_error_title' => 'Erro ao fazer o download', ]; diff --git a/src/resources/lang/pt_br/backup.php b/src/resources/lang/pt_br/backup.php index 93bcb18..f158ffa 100644 --- a/src/resources/lang/pt_br/backup.php +++ b/src/resources/lang/pt_br/backup.php @@ -28,8 +28,7 @@ 'delete_error_message' => 'Não foi possível excluir o backup.', 'delete_cancel_title' => 'Sem problema', 'delete_cancel_message' => 'O backup não foi excluído.', - 'create_confirmation_title' => 'Backup completo', - 'create_confirmation_message' => 'A página será recarregada em 3 segundos.', + 'create_confirmation_title' => 'Backup iniciado.', 'create_error_title' => 'Erro de backup', 'create_error_message' => 'Não foi possível criar o Backup.', 'create_warning_title' => 'Erro desconhecido', @@ -38,4 +37,9 @@ 'no_disks_configured' => 'Não existe configuração de local de backup no arquivo config/backup.php', 'backup_doesnt_exist' => 'O arquivo de backup não existe.', 'only_local_downloads_supported' => 'Somente são suportados downloads do sistema de arquivos local.', + 'unknown_disk' => 'Disco de backup desconhecido.', + 'create_started_message' => 'Por favor aguarde alguns minutos pela conclusão do backup.', + 'create_completed_title' => 'O backup está concluído.', + 'download_confirmation_title' => 'Download iniciado.', + 'download_error_title' => 'Erro ao fazer o download', ]; diff --git a/src/resources/views/backup.blade.php b/src/resources/views/backup.blade.php index a65e7b6..96fd011 100644 --- a/src/resources/views/backup.blade.php +++ b/src/resources/views/backup.blade.php @@ -1,139 +1,198 @@ @extends(backpack_view('layouts.top_left')) @php - $breadcrumbs = [ +$breadcrumbs = [ trans('backpack::crud.admin') => backpack_url('dashboard'), trans('backpack::backup.backups') => false, - ]; +]; @endphp @section('header') -
-

- {{ trans('backpack::backup.backups') }} -

-
+
+

{{ trans('backpack::backup.backups') }}

+
@endsection @section('content') - - -
+{{-- Default box --}} + + +
- - - - - - - - - - - - @foreach ($backups as $k => $b) - - - - - - - - @endforeach - -
#{{ trans('backpack::backup.location') }}{{ trans('backpack::backup.date') }}{{ trans('backpack::backup.file_size') }}{{ trans('backpack::backup.actions') }}
{{ $k+1 }}{{ $b['disk'] }}{{ \Carbon\Carbon::createFromTimeStamp($b['last_modified'])->formatLocalized('%d %B %Y, %H:%M') }}{{ round((int)$b['file_size']/1048576, 2).' MB' }} - @if ($b['download']) - {{ trans('backpack::backup.download') }} - @endif - {{ trans('backpack::backup.delete') }} -
- -
-
+ + + + + + + + + + + + @foreach ($backups as $key => $backup) + + + + + + + + @endforeach + +
#{{ trans('backpack::backup.location') }}{{ trans('backpack::backup.date') }}{{ trans('backpack::backup.file_size') }}{{ trans('backpack::backup.actions') }}
{{ $key + 1 }}{{ $backup->diskName }}{{ $backup->lastModified }}{{ $backup->fileSize }} MB + @if ($backup->downloadLink) + + {{ trans('backpack::backup.download') }} + + @endif + + {{ trans('backpack::backup.delete') }} + +
+
+ +@endsection + +@section('after_styles') + @endsection @section('after_scripts') - -@endsection +@endsection \ No newline at end of file diff --git a/src/routes/backpack/backupmanager.php b/src/routes/backpack/backupmanager.php index 6deac1f..450ea55 100644 --- a/src/routes/backpack/backupmanager.php +++ b/src/routes/backpack/backupmanager.php @@ -17,6 +17,6 @@ ], function () { Route::get('backup', 'BackupController@index')->name('backup.index'); Route::put('backup/create', 'BackupController@create')->name('backup.store'); - Route::get('backup/download/{file_name?}', 'BackupController@download')->name('backup.download'); - Route::delete('backup/delete/{file_name?}', 'BackupController@delete')->where('file_name', '(.*)')->name('backup.destroy'); + Route::get('backup/download/', 'BackupController@download')->name('backup.download'); + Route::delete('backup/delete/', 'BackupController@delete')->name('backup.destroy'); });