# Backups and restore

Continuous WAL archiving, daily base backups kept in the United States (with an encrypted second copy of paid databases), restore windows by plan, point-in-time restore into a new database, named snapshots, daily, weekly and monthly backup schedules, weekly restore tests and exports.

KeelDB backs up every database continuously and restores into a new database, so the original is never overwritten.

## What is backed up

- **Continuous write-ahead log (WAL) archiving.** Every committed change is archived as it happens. When a database is quiet, the current WAL segment is archived at least every **60 seconds** on Launch and Dedicated and every **5 minutes** on Free, which caps how much a single-copy database can lose if its data center is lost.
- **Daily base backups.** A full backup is taken shortly after a database is created, then every day between 02:00 and 03:00 UTC. Each database gets a fixed minute in that hour.
- **Off-server, in the United States, in a first copy for every database and a second copy for paid ones:**
  1. a bucket of the database's own, with an access key that can reach only that bucket (on Free and Launch, a temporary key that KeelDB renews before it expires) and a lock that stops anyone, us included, from deleting backup files earlier: 7 days on Launch, Scale and Dedicated, 1 day on Free (its whole restore window) and for an instant branch (below). Every database in US East (Free, Launch and Dedicated, which all run at AWS) keeps it in **Amazon S3** in AWS's US East region, next to the servers it runs on;
  2. on paid plans, a second copy in Backblaze B2 (US East), encrypted by us before upload with a key that is never given to Backblaze. Where the first copy is in Amazon S3 it is made **once a week**: each root database's newest completed base backup and the WAL archived since it, replacing last week's, so a restore from it reaches the moment of the copy. Branches and [snapshots](#snapshots) are not copied: they are restored from Amazon S3 (a branch can also be made again from its parent). The key that writes it can add files and hide them but cannot delete them; hidden files are deleted 7 days later. Free databases keep their backups 1 day, which a weekly copy cannot follow, so on AWS they have the first copy only.
- Scheduled backups pause while a database is asleep or suspended, since nothing can change while it is stopped.
- **An instant branch keeps no backups of its own** while its parent's history restores it, as on Neon (at most a day of them once it has written as much as its size or its parent is deleted): the parent's backup from before the branch was made is kept for it, with the parent's write-ahead log to the branch's start, and the branch's own log is archived like any database's; its bucket's lock is 1 day. Point-in-time restore, snapshots and backup schedules are for databases, not instant branches. See [Backups of a branch](/docs/branching#backups-of-a-branch).

| Plan | Restore window | Notes |
| --- | --- | --- |
| Free | 1 day | WAL archiving is capped at 5 GB per database per day |
| Launch | Up to 7 days | 7 days by default. Choose a shorter window to keep less restore history. History up to 2 times the storage it is billed for is included, above that $0.05 per GB-month. An instant branch has no restore window of its own; what its own backups keep counts as its history |
| Dedicated `single` | 7 days | Choose a longer window at $0.03 per GB-month |
| Dedicated `ha2` | 14 days | Choose a longer window at $0.03 per GB-month |
| Dedicated `ha3` | 30 days | Choose a longer window at $0.03 per GB-month |

Dedicated sizes include backup storage up to 1.5 (`single`), 2.5 (`ha2`) or 5 (`ha3`) times the provisioned storage; a write-heavy database that needs more pays $0.03 per GB-month for the excess. See [Plans and billing](/docs/plans-and-billing#dedicated).

Backup files older than the restore window are removed, but never earlier than the lock allows (7 days after they were written on Launch, Scale and Dedicated, 1 day on Free and for an instant branch). The encrypted second copy keeps a removed file for up to 7 more days (1 day for Free databases) as a safety net against mistakes and attacks, plus up to 6 hours until its next run; a weekly copy is replaced each week, and the one it replaces is kept 7 more days. While a newer weekly copy of a database cannot be made (its copy failed, which alerts us, or its new servers have no completed backup yet), its last one is kept until one is.

## Restore to a point in time

A restore creates a **new database** with the data as it was at the moment you choose. The original keeps running untouched, so you can compare the two before switching your app over.

In the console, open the database, go to **Backups & restore** and choose **Restore to a point in time**. Pick a date and time in UTC (to the second) and a name. The console shows where the restored database will run and what it costs, by the rules for [branches](/docs/branching#where-a-branch-runs-and-what-it-costs).

With the API, a restore is a [point-in-time branch](/docs/branching):

```bash
curl -X POST https://keeldb.com/api/v1/databases/k7m2x9qa4pz1/branches \
  -H "Authorization: Bearer $KEELDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "restore-0829", "at": "2026-10-07T08:29:00Z"}'
```

The time must be within the database's restore window, after its first backup finished, and not in the future. A restore replays the WAL on top of the last base backup before that time, so it takes longer the more data and WAL there is, about 1.5 hours per TB of data.

After the restored database is `ready`:

1. Check the data, for example with the SQL editor or `psql` on its direct host.
2. Point your app at the restored database. It has its own hostnames and password, with the same database name and user.
3. Delete whichever copy you no longer need.

Things to know:

- The restored database is a branch of the original. The original can't be deleted while the restored copy exists.
- It is billed like any branch. See [Branching](/docs/branching#where-a-branch-runs-and-what-it-costs).
- Its own backups and restore window start when it is created.

## When a server or a data center is lost

Backups are also how single-copy databases survive the loss of their server. In US East:

- **Free, Launch and Scale** databases run on the shared servers of our elastic pool at AWS in Northern Virginia. If one stops responding and our checks from Ashburn, Piscataway and Cloudflare agree that it is lost (about 3 minutes), KeelDB creates a replacement server of the same kind at once, normally in another availability zone of Northern Virginia. Launch and Scale databases are restored from their backups starting 15 minutes after the server stopped responding, and Free databases after 30 minutes, onto the replacement or another of our shared servers that has room, with the same hostname and password. Each restore takes a minute or two for a small database and longer for a large one (about 1.5 hours per TB). Changes since the last archived WAL are lost: up to 60 seconds on Launch and Scale and 5 minutes on Free, as long as archiving was current (KeelDB is alerted when it falls behind). If the old server comes back before the first restore starts, it keeps serving and the replacement is removed.
- **Dedicated `single`** databases keep their storage volume when their server fails: it is attached to a replacement server, with nothing lost. If its whole availability zone of AWS is lost, the database is restored from its backups in the other zone after 15 minutes, unless you chose to wait; up to 60 seconds of changes can be lost.
- **Dedicated `ha2` and `ha3`**, where offered, fail over to a copy in another data center instead. In US East, `ha2` is offered once Dedicated servers open, and `ha3` not yet. See [High availability](/docs/scaling#high-availability).


## Automated restore tests

Once a week, KeelDB restores each database's latest backup into a temporary instance, checks that PostgreSQL starts and is healthy and, on Free, Launch and Scale, that the write-ahead log archive since that backup has no gap, then deletes the temporary instance. Databases asleep, suspended or archived are tested too. A database being set up, upgraded to a new major version (until its first backup of that version), deleted or in error waits, as does a suspended Dedicated database; an instant branch without backups of its own is covered by its parent's test. The result appears next to the backup:

- In the console, under **Backups & restore**, the **Restore test** column shows "Restored OK" or "Failed". Failures alert KeelDB's operators.
- In the API, `restore_test` is `passed`, `failed` or `null` (not tested), with `restore_tested_at`.

## On-demand backups

Take a full base backup at any time, for example before a risky migration. The database stays online.

- Console: **Back up now** on the database's Overview page.
- API: `POST /api/v1/databases/{id}/operations` with `{"kind": "backup"}`, then poll the job. See [Operations and jobs](/docs/api#operations-and-jobs).
- MCP: `run_operation` with `kind: "backup"`.
- [CLI](/docs/cli): `keeldb backups create <id> --wait`.

On-demand backups are listed with `method: "on-demand"` and follow the same restore window. The database must be `ready`. To keep a backup longer than the restore window, take a [snapshot](#snapshots) instead.

## Snapshots

A snapshot is a named copy of a database that KeelDB keeps until you delete it, also after the restore window has passed. Take one before a risky change, like a migration, and restore it later into a **new branch** of the database or a **new database**. The database the snapshot was taken of is never overwritten.

How it works: KeelDB takes a base backup and marks it in the backup storage so the restore window never removes it, together with the write-ahead log the backup needs. A restore brings the data back exactly as it was when the backup finished. A database that is asleep and has had no client since its last backup reuses that backup, without waking up (several snapshots of one backup are billed once); otherwise it wakes for the backup and stays awake until the backup has finished, and that time is billed as compute like any other. A database that scales to zero does not go to sleep while a snapshot of it is being taken.

| Plan | Manual snapshots per database | Price |
| --- | --- | --- |
| Free | 1 | Included |
| Launch | 100 | $0.08 per GB-month |
| Dedicated | 100 | $0.08 per GB-month |

A snapshot is billed on the size of its backup in the backup storage (compressed, so usually smaller than the database), from the hour it was taken until you delete it. Its backup is not also counted as restore history on Launch: each byte is billed once. Snapshot storage counts toward a hard [spend limit](/docs/plans-and-billing#spending-controls), when one applies, like any storage: a snapshot whose storage for the rest of the month would pass it is refused, and a scheduled one is skipped, with an event on the database. Snapshots taken by a [backup schedule](#backup-schedules) are billed the same way and don't count toward the 100.

- Console: **Backups & restore**, then **Take snapshot**. Each snapshot has **Restore** and delete buttons.
- API: see [Snapshots](/docs/api#snapshots).
- MCP: `create_snapshot`, `list_snapshots`, `restore_snapshot`, `delete_snapshot`.
- [CLI](/docs/cli): `keeldb snapshots create`, `list`, `restore` and `delete`.

```bash
curl -X POST https://keeldb.com/api/v1/databases/k7m2x9qa4pz1/snapshots \
  -H "Authorization: Bearer $KEELDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "before-migration-42"}'
```

The snapshot is `creating` until its backup has finished, usually within minutes, then `ready`. To restore it:

```bash
curl -X POST https://keeldb.com/api/v1/databases/k7m2x9qa4pz1/snapshots/snap_8h2k4m1q9x7c3v5b/restore \
  -H "Authorization: Bearer $KEELDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"target": "branch", "name": "before-migration"}'
```

`target` is `branch` (a branch of the database, placed like any [branch](/docs/branching#where-a-branch-runs-and-what-it-costs) and billed like a point-in-time branch: it is a full copy, so all its data counts as its storage, on Free toward the 1 GB the database and its branches share) or `database` (a new database on the same plan, region and PostgreSQL version, with the same database and user names inside, since they are part of the data). Either way the copy gets its own hostname and a new password, and it starts its own backups.

Things to know:

- Snapshots belong to their database: deleting the database deletes its snapshots, and billing for them stops at the deletion.
- A restore takes longer the more data the snapshot holds, about 1.5 hours per TB.
- A Dedicated database on servers of its own can't take snapshots yet; its backups and point-in-time restore work as usual. Snapshots of Dedicated databases on KeelDB's shared servers work, and restore onto them.
- Changing a database's plan keeps its snapshots, with one exception once Dedicated servers open: a database with snapshots or a backup schedule on can't [move between the shared servers and Dedicated servers](/docs/scaling#once-dedicated-servers-open), because the move retires the copy its snapshots are kept with. To keep a snapshot, restore it into a new database first. Changes between Free, Launch and Scale, and every change today, apply in place and keep snapshots.
- A snapshot can't be deleted while a copy is still being restored from it (by hand, or by a schedule's kept count, which deletes it after the copy runs): the restore reads its backup. Copies that finished restoring stay when it is deleted.
- Deleting a snapshot stops its billing at once. Its backup files are then removed by the restore window's normal cleanup, never earlier than the backup storage's lock allows (7 days after they were written on Launch and Dedicated, 1 day on Free).

## Backup schedules

On Launch and Dedicated, KeelDB can take snapshots for you every day, week or month. Each schedule keeps its newest snapshots and deletes the oldest:

| Schedule | Runs | Keeps |
| --- | --- | --- |
| Daily | Every day at the hour you choose (UTC) | 1 to 35 snapshots, 7 by default |
| Weekly | On the weekday you choose | 1 to 26, 4 by default |
| Monthly | On the day of the month you choose, 1 to 28 | 1 to 24, 12 by default |

Scheduled snapshots are named after their run (`daily-2026-10-16-0300`), restore like manual ones and are billed like them. Turning a schedule off keeps the snapshots it took until you delete them. If a run's previous snapshot is still being taken, or the database is suspended or deleted, that run is skipped.

- Console: **Backups & restore**, **Backup schedule**.
- API: [`PUT /api/v1/databases/{id}/backup-schedule`](/docs/api#backup-schedule).
- MCP: `get_backup_schedule`, `set_backup_schedule`.

```bash
curl -X PUT https://keeldb.com/api/v1/databases/k7m2x9qa4pz1/backup-schedule \
  -H "Authorization: Bearer $KEELDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"daily": {"enabled": true, "keep": 7}, "monthly": {"enabled": true, "keep": 12}, "hour_utc": 3, "month_day": 1}'
```

The daily base backups described above run on every plan whatever the schedule says; a schedule adds snapshots that outlive the restore window.

## List backups

```bash
curl https://keeldb.com/api/v1/databases/k7m2x9qa4pz1/backups \
  -H "Authorization: Bearer $KEELDB_API_KEY"
```

```json
{
  "data": [
    {
      "id": "k7m2x9qa4pz1-daily-20261007021700",
      "status": "completed",
      "method": "scheduled",
      "size_bytes": null,
      "started_at": "2026-10-07T02:17:00.000Z",
      "completed_at": "2026-10-07T02:19:41.000Z",
      "restore_test": "passed",
      "restore_tested_at": "2026-10-07T05:02:13.000Z"
    }
  ]
}
```

`size_bytes` is `null` when the size isn't reported. The endpoint returns the 100 most recent backups.

## When you delete a database

Deleting a Free, Launch or Scale database stops it cleanly and waits until the last write-ahead log it wrote is in its backups (a final backup), then destroys its servers and storage. A database that is in error, or that refuses its owner's sign-in, is deleted within 10 minutes without that check, and the wait lasts at most 30 minutes. A Dedicated database is deleted with the backups it has. Its backups are kept for **7 days**, then deleted from the first copy; the encrypted second copy deletes them about 7 days and 6 hours later (1 day and 6 hours later for a Free database). The bucket's access key is deleted with them, or, on Free and Launch, has already expired, because that temporary key is not renewed after the deletion. On Dedicated servers of its own, its storage volumes are deleted with their encryption keys. Delete with care: a deleted database can't be brought back from the console. If you need its data later, export it first.

## Export with pg_dump

Your data is always yours to take. Use the **direct** host (not the pooler) and a `pg_dump` at least as new as the server's major version:

```bash
# Whole database, custom format (compressed, restorable with pg_restore)
pg_dump "postgresql://shop_owner:<password>@k7m2x9qa4pz1.us-east.db.keeldb.com:5432/shop?sslmode=require" \
  --format=custom --no-owner --no-acl --file=shop.dump

# Schema only, as plain SQL
pg_dump "$DIRECT_URL" --schema-only --no-owner --no-acl --file=schema.sql
```

Restore the dump anywhere with `pg_restore`:

```bash
pg_restore --dbname="$OTHER_DATABASE_URL" --no-owner --no-acl --jobs=4 shop.dump
```

Keep your own `pg_dump` exports of anything you must keep longer than your restore window. Moving to another provider? See [Switching](/legal/terms#143-switching-to-another-provider) in the Terms: there is no fee for it.
