In this laravel database backup tutorial, you will learn how to backup of database in laravel apps.
This tutorial will help you step by step to take database backup daily, hourly, weekly, and monthly in laravel apps using the database package.
Laravel Automatic Database Backup Daily, Weekly, Monthly
Follow the below step and take database backup in laravel apps:
Step 1: Install Package
First of all, use the following command to install laravel database package:
cd /project directory Then composer require spatie/laravel-backup
Step 2: Add ServiceProvider
Next step, Navigate to config/app.php file. And then add service provider as follow:
'providers' => [ .... Spatie\Backup\BackupServiceProvider::class,]
Step 3: Publish Vendor Of Package
After that, run the following command to publish vendor folder of installed package:
php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"
Note that, Navigate to app/config/laravel-backup.php, and change configuration details.
Step 4: Backup With Command
Run the following command to download database backup into storage/app/backupfile:
php artisan backup:run
So Navigate to storage/app/backupfile in your storage directory. And find all backups files here.