zarulizham/laravel-database-backup-scheduler

Automate and schedule your Laravel application database to your preferred storage filesystem

1.0.3 2024-08-28 03:31 UTC

This package is auto-updated.

Last update: 2024-12-28 04:15:40 UTC


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.

Credits