SkybuDocs

Ferdigheter · Databaser

Restore a database

Mark a restore point before a risky change, check what a database can be restored to, and have the user take it back in time when something goes wrong.

skill://databases/restore-a-databaseAgenter leser den med resources/read eller skills_read. Den er skrevet på engelsk, for agentene.

Skybu archives every change to a database continuously and takes a base backup every day, and keeps 30 days of them. A database can go back to any moment in that window, in place. Agents can mark and inspect restore points; the restore itself is done by a person, because it throws away everything written after that moment.

In short

  1. Before a migration, a bulk update or a delete: create_restore_point with a name that says why.
  2. Do the change.
  3. If it went wrong, list_restore_points to check the point is ready, then ask the user to restore to it in the dashboard or with skybu db restore.
  4. For a preview's database, reset_preview_database gives it a new empty one instead.

Step 1: mark the moment

{ "name": "create_restore_point", "arguments": { "databaseId": "<database id>", "name": "before the orders migration" } }

A restore point is only a named time, kept by Skybu; making one costs nothing on the database. The name is 1–80 characters. A database keeps up to 100 (restore_points_full; the user deletes old ones on the database's page). The database must be ready (database_not_ready otherwise). Tell the user the name you used, so they can find it.

Step 2: check the points and the window

{ "name": "list_restore_points", "arguments": { "databaseId": "<database id>" } }

The answer has window (from and to: the period the database can be restored to), backups (the base backups in it) and points, newest first, each with id, name, at, createdBy and state:

StateMeaning
pendingThe changes up to it are not archived yet. Becomes ready within a few minutes.
readyCan be restored to.
expiredThe backups no longer reach back to it.
unavailableThe database is being restored or is not ready.

The window ends about two minutes before the last archived change, so the last minutes before "now" cannot be chosen yet. A new database has no window until its first base backup, a few minutes after it is created.

Step 3: restoring (the user does it)

There is no agent tool for restoring. Explain what will happen and give the user one of these:

  • Dashboard: the database's page at https://platform.skybu.no, "Restore to a point in time …". They type the database's name to confirm.
  • CLI:

    skybu db points shop/main                                         # the points and their state
    skybu db restore shop/main --point "before the orders migration"  # back to a named point
    skybu db restore shop/main --to 2026-11-20T14:31:00+01:00         # back to a time
    skybu db restore shop/main                                        # with neither: show the window

    The CLI asks the user to type restore; --yes skips the question.

Tell the user before they do it:

  • Everything written to the database after that moment is lost: orders, sign-ups, every row from every app.
  • Apps lose the connection for the few minutes it takes. The status is restoring, then ready.
  • It restores the whole database; a single table cannot be restored on its own. If only a few rows are wrong, repairing them by hand may lose less.

You can follow the restore with list_projects (the database's status and restoreTo). Errors the user may meet:

CodeMeaning
restore_in_progressA restore is already running.
restore_window_unknownNo base backup yet. Try again in a few minutes.
restore_point_unavailableThe point is outside the window (still pending, or expired).
restore_out_of_windowThe time is outside the window.

Preview databases

Each pull request preview has its own empty database in the same cluster. It is not restored separately: reset it to a new empty one, and the preview restarts against it.

{ "name": "reset_preview_database", "arguments": { "appId": "<app id>", "number": 7 } }

This deletes the preview's data and cannot be undone; ask first. When the preview databases together fill more than a fifth of the database's disk, the largest is paused, and it stays paused until it is reset. get_preview_database_credentials returns its connection strings (DATABASE_URL and DATABASE_URL_DIRECT). Both tools need deployments:write, not secrets:read.

Things to know

  • After a restore the window starts again from a new base backup, and every earlier restore point becomes expired. Choose the moment carefully: there is no going "forward" again.
  • A restore also takes the project's preview databases back to that moment.
  • A deleted database's backups are kept for 30 days. Only Skybu staff can bring one back; the user must contact Skybu.
  • Deleting a restore point keeps the backups; only the name goes.
  • Every restore point and every restore is written to the organisation's audit log.
  • Restore points do not replace a review of the migration. Read it, and test it in a preview first (skill://apps/previews-and-approval). Schema changes run as the owner role (skill://databases/use-the-database).