Today now in this post, i want to show you a example of how to take database backup by using Laravel backup package. In this package will provide us a command to take the backup from our live server and also that command we can use in crontab file on the server, So on that way we can get backup daily on every hourly etc as we want. We know that database backup is very important for our projects.
So i hope this is a proper example and also very simple way to use. Now in this example we can download mysql database backup by using laravel backup package. Here one more thing this will work if we have php 5.5.9 or higher and also Laravel 5.1.2 or higher.
so now let’s start from install “Laravel Backup” package.
composer require spatie/laravel-backup
So now need open config/app.php file and need to add service provider.
'providers' => [ .... Spatie\Backup\BackupServiceProvider::class, ]
Publish Config File
Now in the following command through we can create publish config file for laravel backup package. So after fire this command we can see one file app/config/laravel-backup.php and we can change our own setting.
php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"
Ok good, finally now we are ready to take a mysql database or PostgreSQL backup from application by using bellow command.
Read Also: Laravel manual pagination with array example
php artisan backup:run
Now at last we can find that file into storage/app/backupfile in our storage directory. So in that folder store all backups date-time wise will be save. By using above command we can add on our server cronbob file.
we can take more information about laravel backup package from here : Laravel Package.
Thanks for read. I hope it help you. For more you can follow us on facebook.