Programmatically set backups

Can you make it possible to turn on backups programmatically? It would be great if the backup option could be set at the creation of a database or separately on an existing database. That way, if you have many databases managed by many different users, you won’t have to go through the dashboard every day to make sure their data is being backed up.

Hi @MarcelW thanks for this ask. We are planning to provide and API for Backup and Restore through which you would be able to both configure backups and trigger a recoveries.

Being able to activate backups at time of database creation is a feature that is also on our roadmap. We recognize a need for administrators within an account to be able to set configuration policies, which assure that any new database in a hierarchy has backups set by default. Would such configuration policies be useful to you?

I could imagine creating the backups with a call like this:

Database.byName().backup.create() // Creates a new Backup
Database.byName().backup.all() // Lists all available Backups
Database.byName().backup.all().first().recover() // Replaces the database with the selected database backup


This would become even easier if you combine it with a backup strategy such as D1 from Cloudflare (The whole last 30 days are stored automatically as an append-only log, and I can roll back the database in 1-minute steps.)

Database.byName().recover(Time.now().subtract(20, 'minutes')) // Restores the database in the state it was 20 minutes ago

1 Like