Brewless Brewless Docs

Running your application

Restoring from backups

Restore files, buckets, databases, variables or configuration from a backup, and download the Recovery Kit. Production is never overwritten unasked.

On this page

A restore takes data out of a backup by Brewless and puts it where you say. The backup runner does it in your own Scaleway account: the data goes from the backup bucket to its target there and never passes through Brewless. Brewless only sees names, sizes and times.

By default a restore never writes over what your environment uses. It makes something new next to it: a download, a new bucket or folder, or a new database. You look at it, and only then, with an approval of its own, you switch the environment over. Writing over the environment's own database is possible, but asks twice and takes a snapshot of that database first.

What you can restore

You pick a recovery point (one backup run) and what to take from it.

Restore What happens
Download a file The runner writes the one file into a private bucket of your account (brewless-restore-…), and you get a link that downloads it straight from Scaleway. The link works for an hour after the restore.
Files or folders The keys and folders you name (a folder ends in /) go into a new bucket, or into the bucket they came from, under restore-<restore id>/ inside the folder you name. Brewless makes that folder for the restore alone, so nothing that stands is written over. A key or folder with a . or .. part is refused.
A whole bucket Every object goes into a new bucket, in the same region or another Scaleway region, with its content type, cache and other metadata from the backup's manifest.
Download a database The database as a compressed SQL file (.sql.zst), with a download link like a file.
A database into a new one A new Serverless SQL Database next to the current one, or a new database inside the same Managed Database instance. The extensions the backup used are created first.
A database over the current one Writes over the environment's own database, after two confirmations. See below.
Environment variables The runner compares the backup's variables with today's in your account and you see which differ, by name only. You choose which to take back, and the runner writes them as a new revision of the environment's secret.
Configuration You see the resources of brewless.yml as the backup had them next to today's, key by key, and apply them as a deploy would.

A database restore signs in as the application's own user, so the tables it makes belong to the application and later migrations can change them. The runner reads that sign-in (DB_USERNAME and DB_PASSWORD) from the environment's variables in your Secret Manager itself; Brewless only tells it which secret, and never reads a value. The variables therefore have to be kept through Brewless (brewless env:push). A new database inside a Managed Database instance is given to the user Brewless made for the environment (<application>_<environment>). A new Serverless SQL Database runs PostgreSQL 16: a backup of a newer version gets a warning before you switch over.

A restore goes to Scaleway Object Storage, in any of its regions. To move data to another provider, download it, or use the Recovery Kit.

In the console

Open an environment, choose Backups, and click Restore next to a recovery point. The wizard has four steps:

  1. What: files or a folder of a bucket (one key or folder per line; a folder ends in /), a whole bucket, a database, the environment variables, or the configuration. An item that the backup did not back up is named but cannot be chosen.
  2. Where to: something new is chosen by default. For files: a new bucket in a region you choose, the same bucket under a new folder, or a download of exactly one file. For a database: a new database, a download, or writing over the current one. A whole bucket always goes into a new bucket. The variables and the configuration are compared with the environment first, so they have no target to choose.
  3. Review: what goes where. For a new database, a reminder of the PostgreSQL version check. Writing over the current database asks you to type its name here.
  4. Progress: the steps of the restore while the runner works, then the result. A download gets its link here, and a new database or bucket gets the switch-over.

A variables restore stops at a review once the runner has compared: you see the names that were added, changed or removed since the backup, without values, and tick the ones to take back. Nothing is ticked for you. A configuration restore shows every resource of brewless.yml that differs, today's next to the backup's, and applies them together. Either can be let go instead.

The restores of the environment are listed on the Backups tab. Open picks one up where it was left, for example one that waits for its second confirmation or for your review.

One restore of an environment runs at a time, and none while a restore test of it runs: the two share the restore's rights in your account. Wait for the other to finish.

Switching over

A restore into a new database or a whole new bucket ends with the environment unchanged. Check the data, then approve the switch-over. In the console, Switch over… says what will change and Switch over now starts it:

  • A database: DB_HOST, DB_PORT and DB_DATABASE point at the new database in a new revision of the variables, as a failover does. The environment's variables must be kept through Brewless for that (brewless env:push).
  • A bucket: the new bucket becomes the environment's bucket.

The live release then goes live again with that. The database or bucket from before is let go from the environment and keeps running at Scaleway with its data; Brewless removes nothing.

Writing over the current database

Warning

This replaces what is in the environment's database with the backup. Prefer a restore into a new database and a switch-over.

It takes two confirmations, each naming the database in full: once when you ask for the restore, and again within 15 minutes. At the second, you also confirm that it is you with a code by mail, unless you did so in the last 10 minutes. Only then does the restore start. The console asks for the name in the review, and again on the restore's progress page with the time the confirmation runs out. Before the runner writes, it takes a snapshot of the database as it is into the backup repository, tagged pre-restore, so you can go back to it. The runner carries out an overwrite itself, as it alone may write to the backup repository; for that time only it may also read the environment's variables, to sign in as the application.

Variables

Brewless never reads a variable's value, also not during a restore. The backup runner, in your Scaleway account, compares the backup's variables with the environment's current secret and reports only the names that were added, changed or removed since. You choose which to take back; the runner then writes them as a new revision of the secret: a chosen name gets the backup's value, or goes when the backup did not have it, and every other variable keeps today's value. If the secret changed between the comparison and your choice, the runner refuses and you start again. Brewless records the new revision by its names and checksum, as it does for brewless env:push. The new values reach the containers with the next deploy.

While a variables or database restore runs, the restore identity may read the environment's secret, and for variables also write a new version of it; it loses that right when the restore ends. That right covers this environment's own secret only, not the other secrets Brewless keeps in the project, and it goes to this environment's own restore identity: a restore in test gives nothing to production's.

The variables are only in a backup when secrets are included (backup.secrets: true; off by default).

The Recovery Kit

The Recovery Kit lets you restore without Brewless. Download it from the environment's backups; it is a zip with recovery.json (where every repository is, the recovery points, the databases with their versions and extensions, the buckets, and what is not in the backup) and RECOVERY.md, the steps, the same as at the root of every destination. Neither holds a key: keep the recovery key apart, in a password manager or a safe.

The runner rewrites the kit after every successful backup. When it changed since you last downloaded it, or you never downloaded it, the Recovery Kit card on the Backups tab says so: download it again. The kit is there after the first successful backup.

Who may restore

Restoring needs the right to manage applications; a database restore also needs the right to manage databases. A restore cannot be started, confirmed or downloaded while Brewless support is signed in to your organisation. Every step is in the audit trail.

The command line and the API

The console and the client use the same endpoints:

Endpoint What it does
GET /api/environments/{environment}/backup-restores The restores of an environment
POST /api/environments/{environment}/backup-restores Ask for a restore: key, type, point, item, paths, target.region, target.prefix, target.same_bucket, and confirm for an overwrite
POST /api/backup-restores/{restore}/confirm The second confirmation of an overwrite; 403 with reauthentication_required without a recent confirmation that it is you
POST /api/backup-restores/{restore}/apply Have the runner write the variables named in keys (answers 202 with the operation), or apply the configuration
POST /api/backup-restores/{restore}/switch-over Switch the environment over
POST /api/backup-restores/{restore}/cancel Let a restore that waits go
GET /api/backup-restores/{restore}/download A download link
GET /api/environments/{environment}/recovery-kit Whether the kit changed since it was last downloaded
GET /api/environments/{environment}/recovery-kit/download The Recovery Kit