Backups
Application-consistent backups
Put your application in maintenance mode while its databases are backed up, so nothing writes between one database and the next.
On this page
What it is for
A backup takes each database with a dump that is consistent in itself: every table as it was at one moment. Your application keeps running meanwhile. With two databases, the second is a little later than the first, and the buckets are read after the databases, so a row can point at a file that was uploaded after the dump, or the other way round. For most applications that does not matter. Where it does, application-consistent mode puts the application in maintenance mode while the databases are backed up, so nothing writes in between.
Warning
While the databases are backed up, visitors see your maintenance page and nothing is written. The application's container is woken for it, which costs a little at Scaleway. Choose it knowingly, and choose a backup time when few visitors come.
Note
Application-consistent mode is being rolled out. Until Brewless has switched it on, the setting is kept but backups run as before.
Switching it on
In brewless.yml, per environment:
environments:
production:
backup:
consistent: true
brewless plan shows the change and what it means. It takes effect from the next plan Brewless writes for the backup job.
Maintenance mode has to reach every container of the application, not only the one the command runs in. In Laravel, keep the maintenance state in a cache store all containers share:
APP_MAINTENANCE_DRIVER=cache
APP_MAINTENANCE_STORE=database
Without APP_MAINTENANCE_DRIVER among the environment's variables, Brewless does not put the application down (maintenance_not_shared) and the backup runs as an ordinary one.
What happens during a backup
- Before the first database, the backup job in your account asks Brewless to put the application in maintenance mode. Brewless runs
php artisan down --retry=60in the application's release container, through the same route asbrewless command. - While the application is down, the job dumps every database directly, also one that is otherwise exported from Scaleway's own daily backup: that backup was made earlier and is not consistent with the rest.
- After the last database the job asks Brewless to bring the application back, and Brewless runs
php artisan up. The buckets and the configuration follow with the application running.
The application stays in maintenance mode for 30 minutes at most. After that Brewless brings it back by itself, whatever the job still does; a database still being taken then is not marked consistent. Brewless also brings it back when the job's run ends in any way, and the hourly check of the backups brings back one that was left down.
When Brewless does not put the application down (the setting is off, the shared maintenance state is missing, or the request came late), the backup goes on as an ordinary one, and the run's history says so. Every step is in the audit trail: backup.maintenance_down, backup.maintenance_up, backup.maintenance_refused and backup.maintenance_up_failed.