Backup Laravel and Database

This just helps a lot on backing up database and app, this package is a simple backup was enough even thought you can backup to S3, Rackspace, dropbox and custom ftp.

composer require spatie/laravel-backup

Register Provider

// config/app.php

'providers' => [
// ...
Spatie\Backup\BackupServiceProvider::class,
];
php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"

check config/laravel-backup.php for configurations, pretty straight forward.
to check if the backup is running or not try these command

php artisan backup:run

Before adding to Kernel add this to cron

#* * * * * php /var/www/testing/artisan schedule:run >> /dev/null 2>&1
// app/Console/Kernel.php

protected function schedule(Schedule $schedule)
{
$schedule->command('backup:clean')->daily()->at('01:00');
$schedule->command('backup:run')->daily()->at('02:00');
}

More Info

To backup DB only

php artisan backup:run --only-db

Trouble

Backup failed because: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required

Configure mail, just add mailtrap if dont have any

Subscribe to You Live What You Learn

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe