Laravel Database Backup using Laravel Backup Package

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

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.

Installation Package
composer require spatie/laravel-backup
Add ServiceProvider

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.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →