# S3 storage

> Deploy a standalone MinIO, silo or rustfs store with deploy-s3.yaml and use it as the pgBackRest backup target

---

LLMS index: [llms.txt](/llms.txt)

---

A standalone S3-compatible store gives `backup_target: s3` instances and HA
clusters a shared pgBackRest repository. Three store types are supported, each
with its own example group.

## Activate one store type

`hosts.ini.example` declares all three groups; only one child is active under
`[s3]` at a time:

```ini
[silo_s3]
s3-01 ansible_host=192.0.2.20 private_ip=192.0.2.20 ansible_user=root ansible_port=22

[s3:children]
# minio_s3
silo_s3
# rustfs_s3
```

Copy the matching example group vars:

```bash
cp group_vars/silo_s3/main.yml.example group_vars/silo_s3/main.yml
```

## `group_vars/<type>_s3/main.yml.example`

The example is commented per field; the commonly edited ones:

| Variable | Meaning |
|----------|---------|
| `pgcli_s3_type` | `minio`, `silo` or `rustfs`; must agree with the group name |
| `pgcli_s3_name` | Instance name (default `backup`) |
| `pgcli_s3_api_port`, `pgcli_s3_console_port` | S3 API and web console ports |
| `pgcli_s3_listen` | Bind address; TLS + network boundary guard the store |
| `pgcli_s3_tls` | Serve HTTPS; pgBackRest refuses plaintext HTTP |
| `pgcli_s3_autostart` | Start the store at boot; default `true` |
| `pgcli_s3_root_user` | Root/access user |
| `pgcli_s3_root_password` | Root secret; keep it in `secrets.yaml` for a grid |
| `pgcli_s3_drives` | One directory per drive; empty uses `pgcli_s3_data_dir` |
| `pgcli_s3_data_dir` | Single-node data directory |
| `pgcli_s3_endpoints` | Override the derived endpoint matrix |
| `pgcli_s3_tls_sans`, `pgcli_s3_cert_cn` | Extra SANs / certificate CN |
| `pgcli_s3_tls_cert`, `pgcli_s3_tls_key` | Bring-your-own certificate pair |
| `pgcli_s3_force` | Recreate the container |
| `pgcli_s3_buckets` | Buckets to create after install |

## Layout is derived from hosts and drives

| Hosts | Drives | Mode | Flags per node |
|-------|--------|------|----------------|
| 1 | 0 | SNSD | `--data-dir` |
| 1 | N | SNMD | `--drive` × N |
| >1 | 0 | MNSD | `--data-dir` + one `--endpoint` per node |
| >1 | N | MNMD | `--drive` × N + one `--endpoint` per node per drive |

The endpoint matrix is generated in inventory order from each host's
`private_ip` (falling back to `ansible_host`), so every node receives the same
list. A multi-node grid needs one shared root password and a shared
certificate; single-node stores generate their own CA. `rustfs` has no MNSD:
multi-node requires `--drive` on every node.

## Deploy

```bash
# Active store-type group
uv run ansible-playbook playbooks/deploy-s3.yaml

# Explicit type / subset of nodes / force
uv run ansible-playbook playbooks/deploy-s3.yaml -e pgcli_s3_group=minio_s3
uv run ansible-playbook playbooks/deploy-s3.yaml -e pgcli_s3_nodes=db-01
uv run ansible-playbook playbooks/deploy-s3.yaml -e pgcli_s3_force=true
```

## Use the store as a backup target

In the database mode group (`crosshost`, `ha_cluster`, …), point at one store
node:

```yaml
pgcli_backup_s3_host: s3-01
pgcli_backup_s3_port: 9000
pgcli_backup_s3_bucket: pgbackup
pgcli_backup_s3_access_key: admin
# secret in secrets.yaml: pgcli_backup_s3_secret_key
```

Then set `backup_target: s3` on the instance (fixed at creation time). For HA
clusters, the `pg_ha` role consumes the same `pgcli_backup_s3_*` variables from
`group_vars/ha_cluster`, as shown on the [HA clusters](./ha/) page. The
`pg_instance` role resolves `<private_ip>:<port>`, copies the store CA from
`<base>/tls/<type>/<name>/ca.crt`, and runs `pg backup setup` before creating
the instance.

For a store **outside** this inventory, omit `pgcli_backup_s3_host`, set
`pgcli_backup_s3_endpoint: host:port` (no scheme), and the role falls back to
`pg backup fetch-ca`.

Optional knobs: `pgcli_backup_s3_region`, `_s3_path`,
`_no_verify_tls`, `_ca_file`, `_ca_sha256` (see the mode example files).

## Removal

`deploy-s3.yaml` is deploy-only. Destroy a store on its node with the product
CLI:

```bash
pg addon remove <type> --name <name> --clean-data
```

---

Backlinks:

- [Ansible Deployment](/docs/ansible/)
- [Playbooks](/docs/ansible/playbooks/)
