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...
Hi, If I use spatie media library with Amazon Web Service S3; Would be the images backed-up as well?. It would be better to use another provider to make the backups, wouldn't it? so the backup provider have to be different to any other provider. ok?
By default S3 images will not be backed up. You need to configure that separately. And I'm not sure if this is supported in this package, since it would be huge file moving between two services. For that, there should be better proccessses than using PHP to run them :)
Thanks Modestas,
I understand that the backup of the media have to be other process. Could you point us in any direction to look up taking into account your experience? Another S3-Bucked with "internal S3 script" of backup between buckets? another third party backup service? Is an incremental process (type "Apple Time Machine") possible (exists?)?
I'm not that experienced in this, so sorry, can't 100% recommend anything.