yakovenko/laravel-backup-db

Simple Laravel database backup command with automatic cleanup

v1.0.3 2025-07-08 21:01 UTC

This package is auto-updated.

Last update: 2025-07-08 21:02:04 UTC


README

Latest Version on Packagist Total Downloads License

yakovenko/laravel-backup-db - Simple Laravel database backup command with automatic cleanup options, secure MySQL connection, comprehensive logging, and configurable storage support.

Installation

Requirements

  • PHP : ^8.0
  • Laravel : ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
  • MySQL database
  • mysqldump command available in system PATH

Install the Package

You can install the package via Composer:

composer require yakovenko/laravel-backup-db

Configuration

Publish the config file:

php artisan vendor:publish --provider="Yakovenko\LaravelBackupDb\LaravelBackupDbServiceProvider" --tag=config

This will create config/backup-db.php with the following options:

return [
    // Number of days to keep backups
    'cleanup_days' => env('BACKUP_DB_CLEANUP_DAYS', 15),
    
    // Enable automatic daily backup scheduling
    'auto_schedule' => env('BACKUP_DB_AUTO_SCHEDULE', true),
    
    // Storage disk for backups
    'storage_disk' => env('BACKUP_DB_STORAGE_DISK', 'local'),
    
    // Storage directory for backups
    'storage_directory' => env('BACKUP_DB_STORAGE_DIRECTORY', 'backup'),
    
    // Enable logging
    'logging' => env('BACKUP_DB_LOGGING', true),
];

Automatic Scheduling

The package automatically schedules daily backups when auto_schedule is enabled in config. No need to manually add to Kernel.php!

Usage

Create backup only

php artisan yas:backup --run

Create backup and delete old backups (older than configured days)

php artisan yas:backup --auto

Delete all backups and create new one

php artisan yas:backup --all

Delete only old backups (older than configured days)

php artisan yas:backup --d

Author

License

MIT