zarulizham / laravel-database-backup-scheduler
Automate and schedule your Laravel application database to your preferred storage filesystem
Fund package maintenance!
ZarulIzham
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/db-dumper: ^3.6
- spatie/laravel-medialibrary: ^10.0||^11.9
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
README
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.