# S3 storage

> Store backups in an Amazon S3 bucket or an S3-compatible service.

An S3 storage keeps your backups as objects in a bucket. It works with Amazon S3 and with other services that speak the S3 protocol.

## Prerequisites

- A Clokeep account with the Admin or Operator role.
- A bucket, and an access key that may use it. The permissions it needs are listed below.
- HTTPS access to the bucket from each server you back up and from the Clokeep panel. See [Who connects to whom](/docs/how-clokeep-works#who-connects-to-whom). A bucket that accepts only known addresses must allow [the panel's addresses](/docs/how-clokeep-works#the-panels-addresses).
- For downloads, HTTPS access to the bucket from the browser of whoever downloads. See [Downloads come from the bucket](#downloads-come-from-the-bucket).

## Permissions the access key needs

Both the agent on your servers and the panel use the access key. Allow these actions on the bucket and its objects:

| Action | What Clokeep does with it |
| --- | --- |
| `s3:PutObject` | The agent uploads archives and their indexes. Large archives go up in parts. |
| `s3:AbortMultipartUpload` | The agent cancels a multipart upload that fails, so its parts do not stay behind. |
| `s3:GetObject` | The agent downloads backups to restore them, and reads earlier indexes for incremental backups. The panel checks that backups exist, reads indexes when you browse, and sends you a file or folder when you download it. The download links it hands out for whole backups are signed with this key. |
| `s3:ListBucket` | **Test connection** lists the folders at the top of your **Root path**. The hourly check also needs it to tell a missing backup from a refused one. |
| `s3:DeleteObject` | The panel deletes backups that retention no longer keeps, or that you delete. |

Without delete permission, retention cannot remove expired backups. They stay on the bucket and in the panel, and Clokeep tries again every hour.

Clokeep never deletes the bucket or changes its settings.

## Add the storage

<Steps>
<Step title="Open the form">
Open **Storages** and click **New storage**. Enter a **Name** and pick **S3** under **Driver**.

If **New storage** is greyed out, your client has reached its storage limit. Hover over the button to see it.
</Step>
<Step title="Fill in the connection settings">
- **Bucket**: the bucket's name, such as `example-backups`.
- **Region**: the bucket's region, such as `eu-central-1`. The field starts at `us-east-1`.
- **Endpoint**: leave it empty for Amazon S3. For another S3-compatible service, enter the address it gives you, such as `https://s3.example.com`.
- **Path-style endpoint**: leave it off for Amazon S3. Some S3-compatible services need it on. Their documentation says so.
- **Root path**: the folder inside the bucket that holds your backups, such as `clokeep`, without a leading `/`. The default `/` works, but every object key then starts with `/`, such as `/backups/…`. If your access policy names a folder, enter that folder here instead.

Under **Credentials**, enter the **Access key ID** and the **Secret access key**.

<Frame caption="An S3 storage for an S3-compatible service, filled in before Create.">
![The Create Storage form with the S3 driver, a bucket, region, endpoint, root path and credentials](/images/docs/s3-storage-form.png)
</Frame>
</Step>
<Step title="Test the connection">
Click **Test connection** at the top of the page. **Connection successful** means the panel reached the bucket and listed it with your key. **Connection failed** shows the error the service returned. The test saves nothing.
</Step>
<Step title="Create the storage">
Click **Create**. The storage's page opens. Add the storage to a plan under **Storages** to start using it.
</Step>
</Steps>

## What Test connection proves

The test runs from the Clokeep panel, not from your server. It signs in with your key and lists the top of your **Root path**.

A pass proves that the bucket exists and that the key may list it. It does not prove:

- that your servers can reach the bucket. A server behind a firewall that blocks the endpoint still fails.
- that the key may upload or delete. The test writes nothing.

To check uploads, run a backup with **Run now** once the storage is on a plan.

Every hour, Clokeep tests each active storage again and raises a **Storage unreachable** alert when the test fails.

## Downloads come from the bucket

A whole backup that is not encrypted downloads straight from your bucket, also through a share link or the API. After its checks, the panel sends the browser to a signed link on your storage. The link works for 5 minutes by default. See [Where a download comes from](/docs/restores/download-share#where-a-download-comes-from).

- The browser that downloads must reach your **Endpoint**, or Amazon S3. A bucket policy that accepts only your servers' and the panel's addresses refuses it.
- The bucket needs no CORS rule: the browser follows a plain link, not a script.
- The storage needs an **Access key ID** and a **Secret access key**. Without them, downloads stream through the panel.

Encrypted backups, single files and folders still stream through the panel.

## Folders inside the bucket

A backup's object key is built from three parts: the storage's **Root path**, the **Folder** you set for this storage on each plan, and the archive's name. A plan with no **Folder** uses `backups`. Several plans can share one storage with a folder each. See [Failover between storages](/docs/storage/failover#folders-on-a-storage).

## Change the credentials

On the storage's page, **Credentials** shows "Stored encrypted. Leave a secret blank to keep the saved one." The **Secret access key** field is empty because the panel never shows it again. Leave it empty to keep the stored key, or type a new one to replace it. Click **Test connection**, then **Save changes**.

## Troubleshooting

<Accordion title="Uploads fail with AccessDenied">
The key may not upload to the bucket, or to the **Root path** in it. Check that its policy allows `s3:PutObject` on the objects under your **Root path**. **Test connection** does not catch this, because it does not write.
</Accordion>

## Next steps

<CardGroup cols="2">
<Card title="Failover between storages" href="/docs/storage/failover" icon="layers">
Add a second storage to a plan, and choose the folder each plan writes to.
</Card>
<Card title="Plans" href="/docs/backups/plans" icon="play">
Create a plan that backs up a server to this storage.
</Card>
</CardGroup>
