Laravel — Backup database to your Google Drive

Dennis Smink
5 min readSep 17, 2018

Backups are important, period. You will be needing these once your server or server provider suddenly dies. In this tutorial I will cover how to setup Google Drive backup, with Spatie’s backup package, Googles Flysystem and Laravel.

Requirements

  • Laravel installation
  • Google Drive storage
  • Mysql dump application installed
  • Basic knowledge about PHP and setting up packages in Laravel

Installation

We’ll start with installing Spatie’s backup package:

$ composer require spatie/laravel-backup

If you have auto-discover of or an older Laravel version, register the service provider your self in the config/app.php:

'providers' => [
...
Spatie\Backup\BackupServiceProvider::class
]

Publish the config file:

$ php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"

Schedule it in commands kernel:

// Backups (to Google Drive)
$schedule->command('backup:clean')->dailyAt('01:30');
$schedule->command('backup:run --only-db')->dailyAt('01:35');

--

--