laravel-backup-package maintained by pavliq
Laravel Backup Package
- Installation
composer require pavliq/laravel-backup-package:dev-master
- Create an artisan command
php artisan make:command BackupDatabase
- Open the generated file and add
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Pavliq\LaravelBackupPackage\Services\DatabaseBackupService;
class BackupDatabase extends Command
{
protected $signature = 'app:backup';
public function handle(DatabaseBackupService $service)
{
$service->backupDatabase();
}
}
- Run the command
php artisan app:backup
- Optional: Limit the number of backups
You can set a MAX_BACKUPS variable in your .env file to limit the number of stored backup files.
By default, it keeps 5 backups:
MAX_BACKUPS=5
Database backups will be created in storage/app/backups/db