---
title: "Tested PostgreSQL backups and restores: the while.sh docs"
url: https://while.sh/en/docs/building-blocks/backups/
updated: 2026-11-09
---

# Tested backups

Each database is backed up continuously and every day, and the daily backup of a production database is checked by a real restore. Your agent restores a database to a precise moment in the last 14 days.

> You, to your agent: Restore the database to yesterday at 6 pm.

## What your agent writes

Your agent writes it in while.yaml, at the root of your app:

```yaml titre="while.yaml"
databases:
  - name: main
    backup: { schedule: "0 3 * * *", test_restore: true }
```

## When to use it

They are always there for a database, without declaring anything: go back to a backup or to a precise point in time, over 14 days.

## How it works

Each database is backed up continuously and every day, outside the cluster, and the daily backup of a production database is tested by a real restore. Your agent puts a database back to a backup or to a precise point in time within the last 14 days.

## What to know

Each database archives its log (WAL) continuously and makes a full backup per day, encrypted, outside the cluster. schedule sets the time of this backup, in UTC. Backups are kept 14 days, for all databases: `retention_days` is read, but not followed.

The daily backup of a production database, and any backup started by the `backup_database` tool, is followed by a test: a throwaway database is born from it, and its tables are read back. The result is shown, never assumed.

`restore_backup`, approved by a person, puts a database back to a backup, or to a precise point in time within these 14 days, starting from the last backup finished before that point. The restored database is born new, and takes the old one's place after a safety backup. Backups have a single copy, in a single region.

## Pricing

These prices are the same on every plan, excluding VAT:

| Resource | Price | Details |
|---|---|---|
| Database disk | €0.25 per GiB·month | backups included |

## Your agent's MCP tools

Your agent handles it with the `get_environment`, `backup_database` and `restore_backup` tools.

## Guides

- [Restore your PostgreSQL database to a precise moment, or from a pg_dump, from your AI agent](/en/guides/restore-postgresql/)
