> ## Documentation Index
> Fetch the complete documentation index at: https://ubicloud-00f14c0d-dependabot-npm-and-yarn-mintlify-4-2-808.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Backup and Restore

## Backups

Ubicloud ensures the safety and availability of your data through robust backup and restore processes. Backups are replicated across four servers using erasure coding. This means backups remain accessible even if two of those servers become unavailable.

**Daily Backups:** We take daily full backups. We also store Write-Ahead Log (WAL) files every 60 seconds or 16 MB of WAL updates, whichever comes first. Ubicloud stores these backup files in an internal blob storage service.

Storage for backups are isolated at the bucket level. We create separate buckets for each PostgreSQL server in our blob storage. The credentials provided to each PostgreSQL server only allow access to its own bucket.

**Backup Duration:** We retain backups for a period of 7 days, offering a sufficient window for recovery in case of data loss. If you need a longer backup retention period, feel free to contact us at [support@ubicloud.com](mailto:support@ubicloud.com).

## Download Backups

You can download the backups of your managed PostgreSQL database directly from
object storage. Ubicloud gives you temporary, read-only credentials that are
scoped to your database's own backup bucket. You use these credentials with
standard tools such as [wal-g](https://github.com/wal-g/wal-g), the AWS CLI, or
the MinIO client (`mc`).

<img src="https://mintcdn.com/ubicloud-00f14c0d-dependabot-npm-and-yarn-mintlify-4-2-808/GYERMgssNqPWUjKP/managed-postgresql/backup-download-screenshot.png?fit=max&auto=format&n=GYERMgssNqPWUjKP&q=85&s=9d1e1e1ed000cb7424ccf1c82c5c0ee5" alt="Backup download credentials" width="921" height="519" data-path="managed-postgresql/backup-download-screenshot.png" />

Ubicloud stores backups in WAL-G format: base backups under `basebackups_005/`
and WAL segments under `wal_005/`.

### Availability

* Backup download is available by default for databases on AWS.
* For databases on Ubicloud metal, an administrator must enable it for the project.
* Backup download is not available for read replicas. Request the credentials on the primary database instead.
* Backup download is not available for GCP-hosted databases.
* You need the `Postgres:view` permission on the database.

### Get download credentials

The credentials are read-only. They expire after 36 hours. Ubicloud creates a
new set each time you ask and does not store them. To get a new set, you can
request the credentials again via the web console, API and CLI.

To obtain the credentials from the web console, go to the Backup/Restore tab for
your Ubicloud PostgreSQL database. In the Backup Download Access panel, click
"Get download credentials". The console shows the credentials and example
commands. The secret and session token are hidden until you click to show them.

The web console also shows example commands to use the credentials to access the
backups with tools like `aws s3 sync`, `mc mirror` and `wal-g`.

## Restore

To restore a database, use the "Fork" functionality available in the Backup/Restore view.

<img src="https://mintcdn.com/ubicloud-00f14c0d-dependabot-npm-and-yarn-mintlify-4-2-808/GYERMgssNqPWUjKP/managed-postgresql/backup-and-restore-1.png?fit=max&auto=format&n=GYERMgssNqPWUjKP&q=85&s=31cc624a7c4d146bd0673090198bbeec" alt="Backup and Restore" width="1600" height="212" data-path="managed-postgresql/backup-and-restore-1.png" />

Two input boxes, one textbox for server name of restored database and the other is a date time picker for target restore time.
You can select the target date for the restore at per minute granularity; and specify the name for the new database server. This restore operation creates a new instance with the state of your database as it was at the selected point in time.

## Restoring a Deleted Database

Even if you delete your database, we still keep backups for 7 days. You can restore a deleted database by opening a support ticket.
