Delete all files in Backblaze bucket – terminal

Before being able to delete a bucket in Backblaze b2, you need to delete all the files within the bucket. If you have a lot of files in the bucket, doing this via the user interface simply doesn’t work. A much more efficient way to delete all files in a bucket is using the b2 command line tool which can be downloaded here. Be sure to change the permissions of the file to be executable with the following:

chmod +x b2-linux

Step 1 – Authorize your account

To authorize your account on the command line, you can run the following command:

./b2-linux authorize-account [<KeyID>] [<ApplicationKey>]

Step 2 – Remove files from the bucket

To remove all files from a bucket on the command line, you can run the following command:

b2 rm --versions --recursive <bucketName>

To remove all unfinished large files from a bucket, you can run the following command:

b2 cancel-all-unfinished-large-files <bucketName>