How Can I Easily Delete All Files in a Bucket?

There are two ways that you can delete all Files in a Bucket, the First is through the Command Line Tool, and the Second is through the Web UI.

 

Command Line Tool:

 

To easily delete all files in a bucket, first, install the B2 Command Line tool installed on the computer. If assistance is needed with setting up this installation, please refer to our Command Line tool documentation here

 

Once the Command Line tool is installed, follow these steps:

1) Open Terminal.
2) Create a new local directory (e.g., mkdir empty)
3) Change into that directory (e.g., cd empty)
4) Run the command:  b2 authorize-account [<Key ID>] [< Application Key>] 
5) Run the following command: b2 sync --delete . b2://mybucketname where mybucketname is the name of the bucket you wish to remove.

Newer version (7.3.x forward) of the cli will require you to use the --allowEmptySource argument.  The command would look like this:

b2 sync --allowEmptySource --delete . b2://mybucketname

This will sync the empty contents of the local directory to the bucket.  

 

However, if there are still unfinished large files in the bucket, this method by itself will not remove those unfinished listings. The bucket may still report as not being fully empty.

In order to remove unfinished large files, call b2 cancel_all_unfinished_large_files mybucketname. Then, try to delete the bucket once more.

 

Web UI:

 

1. Login to your Backblaze.com account and go to the page named "browse files" under the "B2 Cloud Storage" heading.

 

2. Once there you will want to select which bucket you wish to delete files from the list of buckets

 

Screen_Shot_2021-01-07_at_3.07.31_PM.png

3. Once the bucket is selected, click the checkmark at the top of the file list next to "Name" to select all files in the bucket, and then click on the button labeled "delete"

deleteall.png

Please note that if you have a very large number of files to delete that the CLI method is better equipped to handle large deletions.

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk