laravel-database-backup-scheduler maintained by zarulizham
Description
Automate and schedule your Laravel application database to your preferred storage filesystem
Author
Last update
2024/08/28 05:31
(dev-main)
License
Downloads
636
Automate and schedule your Laravel application database to your preferred storage filesystem
Installation
You can install the package via composer:
composer require zarulizham/laravel-database-backup-scheduler
You can publish and run the migrations with:
php artisan vendor:publish --tag="database-backup-scheduler-migrations"
php artisan migrate
This package relies on spatie/media-library. If your project did not use spatie/media-library package, publish its migration and/or config file.
php artisan vendor:publish --tag="medialibrary-config"
php artisan vendor:publish --tag="medialibrary-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="database-backup-scheduler-config"
To custom location of backup path, refer Spatie documentation
This is the contents of the published config file. You may modify as per your needs.
return [
'connections' => [
'mysql' => [
'excludeTables' => [],
'storage' => env('FILESYSTEM_DISK', 'local'),
],
],
];
Usage
Place these two scheduler in app/Console/Kernel.php (<= Laravel 10) or routes/console.php (>= Laravel 11)
$schedule->command('db:backup')->dailyAt('00:00')
->environments('production');
$schedule->command('db:backup:prune')->dailyAt('00:00')
->environments('production');
To specify custom retention days for backup, specify --days option on db:backup:prune command. Default 14 days.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.