当前位置:网站首页>Laravel 8 realizes database backup through task scheduling

Laravel 8 realizes database backup through task scheduling

2022-06-11 16:07:00 Chenqing Nuo language

The article only comes from the practice summary , Share with you , There is a problem , Welcome to point out

composer install

composer require spatie/laravel-backup

Publish profile , produce config/backup.php

php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"

stay App\Console\Kernel Write code

protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')->hourly();

        // Execute every minute 
        $schedule->command('backup:run --disable-notifications')->everyMinute();
    }

stay config/filesystems.php Modify the backup save location ( Save to public Under the zip Next )

'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => public_path('zip'),
        ],

Perform backup tasks

php artisan schedule:work
原网站

版权声明
本文为[Chenqing Nuo language]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111554494434.html