How to: off-site backups for hosted databases

Hi all,

I run multiple databases on, including MySQL and PostgreSQL databases. takes snapshots of these, which is great for restoring your DB in case something goes wrong! However, it doesn’t cover certain scenarios:

  1. Me after a night out “cleaning up” our company account and removing the whole DB app, thinking it’s not used anymore. Hasn’t happened yet, but it’s not impossible :wink:
  2. The whole infrastructure going down in a burning fire. Much less likely, but also not impossible :eyes:

I like to prepare for the worst case scenario.

I’ve used spatie/laravel-backup before and started implementing that in my apps, as part of the apps themselves:

So in this setup the app itself backs up its own DB.

This works quite well except there’s two disadvantages:

  1. laravel-backup only works for Laravel apps. I also run some Symfony and Rails apps, I’m left in the dark there.
  2. Installing laravel-backup in every app is kind of a pain. It takes some time to properly configure the S3 credentials, create a scheduler, configure notifications etcetera.

So I wanted to see how easy it would be to make a single app that periodically makes backups of all the databases that are hosted on our Fly account. This way I won’t have to add and configure laravel-backup on all accounts.

After some playing around with laravel-backup, I noticed this is quite easy to do. You just have to define a connection in config('database.connections') for each DB that you want to back up and configure those in config('backup.source.databases') so you end up with this situation:

  • Now you don’t need to add laravel-backup to every app.
  • This also works for other kinds for the DBs backing your Rails or Symfony apps.

If anyone might find this useful, I’ve extracted it to a public repository: GitHub - dejagersh/fly-off-site-backup-manager: Automate creation of off-site backups hosted on In the end it’s just a stripped down Laravel app running laravel-backup which:

  • Periodically makes back ups of specified databases
  • Writes these to e.g. S3.
  • Sends notifications to e.g. Slack on failure/success
  • Cleans up backups if they get too old.

Let me know if you have any suggestions or improvements!