Tuesday, July 26, 2016

Laravel 5 database backup | How to backup your database using Laravel Backup package?

Laravel Database backup



It's a good habit if you maintain a backup database of your project. So that every update of your database will be kept track. Or otherwise some deleted some data by mistake you can keep track of that too.

Before we start make sure you have mysqldump installed in your system. By default it already came with the XAMPP/ LAMP/ WAMP etc. But we need to add the following line in config/database.php in mysql array (for laravel only):

'dump_command_path' =>'C:\xampp\mysql\bin',
Now Let's start How you can backup your database in Laravel

1. First you need to install a package in your application.

composer require spatie/laravel-backup
2. Add the following line in providers Array of config/app.php file.
Spatie\Backup\BackupServiceProvider::class,
3.Then run the following command:
php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"
4. Now if you run the following command it will automatically create a backup database with date in storage/app folder in zip format.


 php artisan backup:run

















Related Articles

0 comments:

Post a Comment