# Keep a second copy of your backups

> Keep your backups in a second bucket at another provider, and see what they cost.

Source: https://rowsafe.sh/docs/guides/second-copy

One bucket is one place that can go wrong: deleted by mistake, an account locked, an outage, leaked keys. A **second copy** keeps everything (backups and the change log for restoring to any second) in a second bucket, ideally at **another provider**. That's the 3-2-1 rule: your database, two copies of its backups, one somewhere else.

- Your database **never waits** for it. If the second storage is down, backups go on in the first, Rowsafe alerts you, and the copy catches up by itself.
- It has its **own access key and passphrase**, kept on your server. Rowsafe never sees them.
- A **full backup goes into it every week** (Sunday 03:30 UTC); the last 2 are kept. **Proof** alternates between the two storages.
- The Storage page shows **what each storage holds and costs**.

## Add a second copy

### Create a bucket at another provider

An empty, private bucket and a key that can read, write and delete, like the first. See [Set up backup storage](https://rowsafe.sh/docs/guides/storage). Pick a **different provider** if you can (say Backblaze B2 when the first is Cloudflare R2).

### Run one command on the database server

The dashboard shows it, filled in, under **Rewind → Storage → Add a second copy**:

```sh
curl -fsSL https://rowsafe.sh | sudo sh -s -- --add-storage
```

It asks for the bucket URL and key, tests the bucket, and **makes a new passphrase**, shown once: save it next to the first. It refuses the bucket you already use.

This is a server step because the key and passphrase must never leave the server.

### Rowsafe does the rest

Within a minute, PostgreSQL sends its change log to both storages (`archive_command` updated, config **reloaded**, **no restart**). The first full backup into the copy starts right away. The dashboard dialog shows when it's ready.

> **Note:** On a server without the dashboard, add it with `sudo rowsafe secondcopy add` instead: see [Rowsafe on your server](https://rowsafe.sh/docs/guides/no-account-server#keep-a-second-copy).

**Without a terminal**

Put the settings in the environment. The installer tests them before saving:

```sh
curl -fsSL https://rowsafe.sh | sudo \
  ROWSAFE_REPO2_S3_ENDPOINT=s3.eu-central-003.backblazeb2.com ROWSAFE_REPO2_S3_REGION=eu-central-003 \
  ROWSAFE_REPO2_S3_BUCKET=mycompany-rowsafe-copy ROWSAFE_REPO2_S3_KEY=... ROWSAFE_REPO2_S3_KEY_SECRET=... \
  ROWSAFE_REPO2_CIPHER_PASS="$(openssl rand -base64 48)" sh -s -- --add-storage --no-prompt
```

Store that passphrase in your secret manager first. All settings: [Agent configuration](https://rowsafe.sh/docs/reference/agent-configuration#second-copy).

## Keep backups away from the server

If your backups are at the same provider **and** in the same region as the server, Pulse says "Backups are in the same region as the server", with **Add a second copy**. Another region or another provider is fine.

Rowsafe knows where a server is when it created it, and reads a bucket's place from its URL. When it can't tell (your own server, MinIO), it says nothing.

## When the second storage is down

PostgreSQL and the first storage aren't affected. Each change log file reaches the first storage, then waits in a queue on the server for the second.

- Files wait in `/var/lib/rowsafe/copy2-queue` and go out in order once it works again.
- After 10 minutes, Health shows **The second copy isn't getting your backups** with the error. The **Second copy not up to date** alert fires after 30 minutes (change it under Alerts).
- The queue holds at most 256 files (4 GiB with default WAL size), so it can't fill your disk. Past that, newer files are left out: the Storage page says **Needs a full backup**, and **Back up to the second copy** fixes it.

The cause is usually a new key or a deleted or renamed bucket. Fix it on the server with `--add-storage`, and test both with `--check-storage`.

## Restore from the second copy

Proof restores from it every other week. **Run Proof from it** on the Storage page does it now. By hand, use its own pgBackRest config:

```sh
sudo -u postgres pgbackrest --config=/etc/rowsafe/pgbackrest/NAME.copy2.conf --stanza=NAME info
```

Everything in [Restore a database](https://rowsafe.sh/docs/guides/restore) works with that `--config`. If the server is lost, you need the copy's bucket settings and passphrase: keep them with the first ones.

On a server without the dashboard, `sudo rowsafe restore NAME --to TIME|MARK --second-copy` restores a copy from it next to production, even when the first bucket is gone.

## What your backups cost

**Rewind → Storage** shows each storage's size (measured every 6 hours and after each backup) and an estimated monthly bill:

| Provider                  | Price used                                                                                                                         |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Cloudflare R2             | $0.015 per GB-month. The first 10 GB of an account are free each month (not subtracted: other things in the account may use them). |
| Amazon S3                 | S3 Standard, $0.023 per GB-month (US East; other regions and storage classes differ).                                              |
| Backblaze B2              | $6.95 per TB-month. The first 10 GB are free.                                                                                      |
| Wasabi                    | $7.99 per TB-month, at least 1 TB per account, and deleted data stays billable for 90 days.                                        |
| DigitalOcean Spaces       | $5 a month for 250 GiB for the whole account, then $0.02 per GiB.                                                                  |
| Others (MinIO, Ceph, ...) | Unknown: sizes only.                                                                                                               |

List prices from September 2026, before taxes and request fees. Rowsafe can't see your real bill. The page also shows the last 90 days of size.

Health may suggest:

- **Backups grew by more than half in 30 days** (and by 5 GB or more). Usually the database grew or changes a lot.
- **Keep one full backup fewer to save about $X a month**, with **Apply fix**. Offered only when it saves $0.10 a month or more and leaves at least 2 full backups per storage (or 1 when the other storage has a complete, working copy). The oldest full backup goes at the next backup, and the recovery window shrinks (the confirmation says by how much).

## Turn the second copy off

```sh
curl -fsSL https://rowsafe.sh | sudo sh -s -- --remove-second-copy
```

Backups go to the first storage only (`archive_command` reloaded). What's in the second bucket stays: delete it at your provider when you're done.

## MySQL, MariaDB, MongoDB and ClickHouse

The other engines work too: weekly full backups go to the second storage with its own passphrase, and Proof alternates.

- **MySQL, MariaDB, MongoDB**: the binary log or oplog is copied there as well, so it can restore to any second.
- **ClickHouse**: restores to its weekly full backups.
- **Redis and Valkey**: weekly snapshots and the stream of changes go there, so it can restore to any second.

## Limits

- One second copy per server, shared by every database on it.
- It gets weekly full backups, not the daily differential ones, so restoring from it replays more change log.
- In Docker (agent as a sidecar), set it up with `ROWSAFE_REPO2_*` in the agent's `env_file`.
