How to backup database or Laravel App
Learn How to backup database on Laravel App. Remember to always backup your database, never underestimate what happen tomorrow
Never underestimate what might happen tomorrow. No one know when your app got hacked or when you accidentally do something wrong with your production database.
ALWAYS BACKUP.
If you use laravel as backend framework, good news, the company Spatie already make one package for use to backup our laravel app or our database. Here is the repo Spatie Laravel-Backup
Later, we just need to run the command
php artisan backup:run
and done! of course you can automate this task via cron job.
Put this command at app/Console/Kernel.app
protected function schedule(Schedule $schedule){
//backup and clean backup
$schedule->command('backup:clean')->weekly();
$schedule->command('backup:run --only-db')->twiceDaily(11, 23)->timezone('Asia/Singapore');
}
You can adjust the command with your need. Above command will run the cleaning weekly (remove old database at your storage) depend on your setting and run only database backup twice daily with specific timezone.
Checkout the documentation for more info