> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.zata.prathamchopde.site/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.zata.prathamchopde.site/_mcp/server.

# Delete a large bucket

For most buckets, **Delete All Contents** in the console is enough: see [Delete a bucket](/buckets/delete-a-bucket). A bucket with hundreds of thousands or millions of files can be too big for that. Empty it first with one of the methods below, then delete it.

> **Warning**
>
> Both methods delete files for good. Copy anything you still need before you start.

|           | Lifecycle rules (recommended)        | rclone or AWS CLI                                     |
| --------- | ------------------------------------ | ----------------------------------------------------- |
| Runs on   | The Zata storage cluster             | Your computer or server                               |
| Takes     | A few days (rules run once a day)    | Minutes to hours, depending on the number of files    |
| Works for | Any size, with or without versioning | Buckets where versioning was never turned on          |
| You need  | The Zata console                     | An access key, the tool, and a computer that stays on |

## Method 1: Lifecycle rules

The storage cluster deletes the files for you, so the size of the bucket does not matter.

#### Add a lifecycle rule

Open the bucket's [settings](/buckets/bucket-settings), expand **Lifecycle Rules** and select **Add lifecycle rule**.

#### Tick the cleanup actions

Tick these actions and set each one to **1** day:

* **Expire objects**
* **Discard unfinished uploads**: unfinished uploads are hidden from the file list but still block deleting the bucket.
* **Clear old versions**, if the bucket has or had versioning. Leave **keep newest** empty.

Select **Next**.

![New lifecycle rule step 1 with Expire objects, Clear old versions and Discard unfinished uploads ticked](/_fern-img/293cacdb84c4248a4520e8d4e406291ba3fa6fcf96a22532554618ddb0584c2c.webp)

#### Apply it to the entire bucket

Choose **Entire bucket** and select **Create rule**. Do not use a filter: files outside it would stay and the bucket could not be deleted.

![Step 2 with Entire bucket selected and the rule summary](/_fern-img/5a773b71e8efac1ee10f47153ff7b3183734f80cf3adfb35d45d1396a115ac62.webp)

#### Add a second rule for delete markers (versioned buckets only)

If the bucket has or had versioning, add another rule with only **Tidy delete markers**, for the **Entire bucket**. It cannot share a rule with **Expire objects**.

![New lifecycle rule with only Tidy delete markers ticked](/_fern-img/0194241a8222168224cbb3d2965aa50ea9c25a6e485ff61f14291e4c53f2b370.webp)

#### Wait, then delete the bucket

Rules run once a day, and in a versioned bucket each step follows the one before. Check the bucket every day. When it is empty (with **Show Versions** on, too), [delete it](/buckets/delete-a-bucket).

In a bucket with [Object Lock](/buckets/object-lock/overview), locked versions are skipped until their lock ends.

## Method 2: rclone or the AWS CLI

Use this for a bucket where versioning was never turned on. In a versioned bucket these commands only hide the files behind delete markers: the old versions stay and the bucket cannot be deleted. Use Method 1 for those.

#### rclone

Create a `zata` remote with the account owner's key from the bucket's region (for Mumbai, use `https://bom01.zata.ai`). See [rclone](/connect/command-line/rclone-linux) for details.

**`Create the remote`**

```bash Create the remote
rclone config create zata s3 provider=Other access_key_id=YOUR_ACCESS_KEY secret_access_key=YOUR_SECRET_KEY region=us-east-1 endpoint=https://idr01.zata.ai force_path_style=true no_check_bucket=true sign_accept_encoding=false
```

Check what is in the bucket, then preview the deletion:

```bash
rclone size zata:my-bucket
rclone purge zata:my-bucket --dry-run
```

Delete all files and the bucket itself. There is no confirmation and no undo:

```bash
rclone purge zata:my-bucket --fast-list --checkers 32 -P
```

`--checkers 32` deletes 32 files at a time, `--fast-list` lists the bucket with fewer requests and `-P` shows progress. To empty the bucket but keep it, use `rclone delete zata:my-bucket -P` instead.

#### AWS CLI

Use a `zata` profile with the account owner's key, set up as in [AWS CLI](/connect/command-line/aws-cli). Delete all files, then the empty bucket:

```bash
aws s3 rm s3://my-bucket --recursive --profile zata
aws s3 rb s3://my-bucket --profile zata
```

> **Tip**
>
> Deleting millions of files can take hours. Run the command inside `tmux` or `screen` so that a dropped SSH connection does not stop it.

If the bucket still will not delete, it usually has unfinished uploads: see [If the bucket will not delete](/buckets/delete-a-bucket#if-the-bucket-will-not-delete).

## Need help?

If a bucket does not empty, [raise a support ticket](/help/support) with the bucket name, its region, roughly how many files it holds, the method you tried and the exact error.