> ## Documentation Index
> Fetch the complete documentation index at: https://www.towbar.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# S3 compatible and Cloudflare R2

> Configure generic S3-compatible storage or Cloudflare R2 for backups and restores.

Towbar provides separate `s3` and `r2` integration slugs with the same field
model. Use `s3` for another S3-compatible service and `r2` for Cloudflare R2.

## S3-compatible storage

```dotenv theme={"system"}
TOWBAR_S3_ENABLED=true
TOWBAR_S3_ENDPOINT=https://objects.example.com
TOWBAR_S3_REGION=us-east-1
TOWBAR_S3_BUCKET=towbar-backups
TOWBAR_S3_PREFIX=production
TOWBAR_S3_ADDRESSING_STYLE=auto
TOWBAR_S3_ALLOW_PRIVATE_NETWORK=false
TOWBAR_S3_ACCESS_KEY_ID=<access-key-id>
TOWBAR_S3_SECRET_ACCESS_KEY=<secret-access-key>
```

Set `TOWBAR_S3_ADDRESSING_STYLE` to the mode required by the service. Keep
private-network access disabled unless the endpoint intentionally resolves to a
private address. A private CA can be supplied as Base64 through
`TOWBAR_S3_CUSTOM_CA_BASE64`.

## Cloudflare R2

```dotenv theme={"system"}
TOWBAR_R2_ENABLED=true
TOWBAR_R2_ENDPOINT=https://<account-id>.r2.cloudflarestorage.com
TOWBAR_R2_REGION=auto
TOWBAR_R2_BUCKET=towbar-backups
TOWBAR_R2_PREFIX=production
TOWBAR_R2_ADDRESSING_STYLE=path
TOWBAR_R2_ALLOW_PRIVATE_NETWORK=false
TOWBAR_R2_ACCESS_KEY_ID=<access-key-id>
TOWBAR_R2_SECRET_ACCESS_KEY=<secret-access-key>
```

Run `sudo towbar config validate`, then `sudo towbar restart`. The corresponding
provider appears only when its enabled configuration is complete. Test a backup
and restore with the intended prefix, retention, versioning, and encryption
policy. Rotate keys by applying the new environment values, verifying a real
operation, and then revoking the old key.

See [Database backups](/docs/backups) and the [environment variable
guide](/docs/self-hosting/environment-variables#registries-storage-secrets-platform-and-telemetry).
