An admin interface for managing backups (download and delete). Used in the Backpack package, on Laravel 5.2+
Please subscribe to the Backpack Newsletter so you can find out about any security updates, breaking changes or major features. We send an email every 1-2 months.
- In your terminal
$ composer require backpack/backupmanager
- For Laravel <5.5, add the service providers to your config/app.php file:
Spatie\Backup\BackupServiceProvider::class,
Backpack\BackupManager\BackupManagerServiceProvider::class,
- Publish the config file and lang files:
php artisan vendor:publish --provider="Backpack\BackupManager\BackupManagerServiceProvider"
- Add a new "disk" to config/filesystems.php:
// used for Backpack/BackupManager
'backups' => [
'driver' => 'local',
'root' => storage_path('backups'), // that's where your backups are stored by default: storage/backups
],
This is where you choose a different driver if you want your backups to be stored somewhere else (S3, Dropbox, Google Drive, Box, etc).
- [optional] Add a menu item for it in resources/views/vendor/backpack/base/inc/sidebar.blade.php or menu.blade.php:
<li><a href="{{ url(config('backpack.base.route_prefix', 'admin').'/backup') }}"><i class="fa fa-hdd-o"></i> <span>Backups</span></a></li>
-
[optional] Modify your backup options in config/backup.php
-
[optional] Instruct Laravel to run the backups automatically in your console kernel:
// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('backup:clean')->daily()->at('04:00');
$schedule->command('backup:run')->daily()->at('05:00');
}
- Check that it works
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:
'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' => '/Applications/MAMP/Library/bin/', // only the path, so without `mysqldump` or `pg_dump`; this is a working example from MAMP on Mac OS
'use_single_transaction',
'timeout' => 60 * 5, // 5 minute timeout
// 'exclude_tables' => ['table1', 'table2'],
// 'add_extra_option' => '--optionname=optionvalue',
]
],
Point and click, baby. Point and click.
Try at your-project-domain/admin/backup
- change your required version to
"backpack/backupmanager": "^1.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 thedump
array from there and customize;
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING for details.
If you need to modify how this works in a project:
- create a
routes/backpack/backupmanager.php
file; the package will see that, and load your routes file, instead of the one in the package; - create controllers/models that extend the ones in the package, and use those in your new routes file;
- modify anything you'd like in the new controllers/models;
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please subscribe to the Backpack Newsletter so you can find out about any security updates, breaking changes or major features. We send an email every 1-2 months.
Backpack is free for non-commercial use and 39 EUR/project for commercial use. Please see License File and backpackforlaravel.com for more information.