In this tutorial you will learn about the Laravel 7 Database Backup Example Tutorial and its application with practical example.
In this laravel database backup tutorial, I’ll show you how to take backup of database in laravel apps. In tutorial you will learn to take database backup in laravel application. 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 7 Database Backup Example Tutorial
Step 1: Install Package
1 2 3 4 5 |
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:
1 |
'providers' => [ .... Spatie\Backup\BackupServiceProvider::class,] |
Step 3: Publish Vendor Of Package
1 |
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
Now run the command given below to download database backup into storage/app/backupfile:
1 |
php artisan backup:run |
Go to storage/app/backupfile in your storage directory.