# Back up WordPress to Cloudflare R2

> Set up encrypted daily WordPress backups to your own Cloudflare R2 bucket with Vantuly, and restore with one click and undo.

Source: https://vantuly.com/docs/guides/wordpress-backups-r2

Cloudflare R2 is a good home for WordPress backups: storage is cheap and there are no egress fees, so restoring costs nothing extra. This guide sends daily, encrypted backups of a WordPress site's files and database to your own R2 bucket. Backups to your own storage work on the free plan too.

**You need:** a Cloudflare account with R2 turned on, and a WordPress site on a Vantuly server.

## 1. Create the bucket and token in Cloudflare

1. In the Cloudflare dashboard, open **R2** and create a bucket, for example `vantuly-backups`.
2. Copy your **Account ID** from the R2 overview page.
3. Open **Manage R2 API tokens** and create a token with **Object Read & Write**, limited to that bucket.
4. Copy the **Access Key ID** and **Secret Access Key**. The secret is shown only once.

## 2. Add the bucket to Vantuly

1. Go to **Settings → Storage → Add storage** and pick **Cloudflare R2**.
2. Paste the **Access key ID** and **Secret access key**, and enter the **Bucket** and **Account ID**. The endpoint is filled in for you and the region stays `auto`.
3. Click **Test connection**, then save.

You add storage once per team. Every site can use it, and each server gets its own folder in the bucket.

## 3. Turn on backups for the site

Open the WordPress site's **Backups** tab and click **Turn on backups**:

| Setting | Options |
|---|---|
| **Frequency** | Daily, every 6 hours, or weekly (Sunday) |
| **Keep** | 14 daily + 4 weekly, 7 daily, 30 daily, or 3 daily |
| **Contents** | Files and database, or the database only |

For most WordPress sites, **Daily** with **14 daily + 4 weekly** and **Files and database** is a good start. The Free plan keeps 3 daily backups. Click **Back up now** to take the first one right away.

## What happens on each backup

- The database is dumped with `mariadb-dump` and backed up with the site's files. Logs and caches are left out.
- Backups use [restic](https://restic.net): encrypted on your server before they are uploaded, and deduplicated, so each daily backup uploads only what changed.
- They run from a systemd timer on the server, so they keep running even if the Vantuly panel is unreachable.
- You get an email when a backup fails.

## Restore

1. On the site's **Backups** tab, click **Restore** on a backup.
2. Choose the whole site or only the database.
3. Type the site's domain to confirm, and enter your password.

Right before restoring, Vantuly takes a snapshot of the site as it is (shown as **Before restore**) and keeps it for 24 hours, so you can undo the restore. See [Restore a site](/docs/backups/restore).

## Next

- [Schedule and retention](/docs/backups/schedule)
- [Google Drive](/docs/backups/google-drive), [Backblaze B2](/docs/backups/backblaze-b2) and [other storage](/docs/backups)
- [WordPress on Hetzner in 10 minutes](/docs/guides/wordpress-on-hetzner)
