Now that we have some features and the project is coming along - we should think about the worst...
What if we lose the data?
Like with the code in GitHub - we should also create database backups!
Seriously, backups are one of those things we don't think about until it's too late. So, let's get ahead of the curve and add backups to our project.
Adding Backups
For our backups, we will use the good old Spatie Backups package. It's tested, reliable, and easy to use.
First, let's install the package:
composer require spatie/laravel-backup
Then publish the configuration file:
php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"
And that's it for the installation. Now, we need to configure the package.
Configuring Backups
We need to edit the config/backup.php
file to configure our backups. In this case, we want to add s3
as an additional disk to store our backups:
config/backup.php
// ... /* * The disk names on which the backups will be stored. */'disks' => [ 'local', 's3',], // ...
Note: Don't forget to configure your S3 credentials in the .env
file.
Other settings are personal preference, but we could recommend...