LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

b2

Command-line interface for Backblaze B2 cloud storage.

TLDR

Authorize account
$ b2 account authorize [applicationKeyId] [applicationKey]
copy
Upload a file
$ b2 file upload [bucketName] [localFile] [remoteFileName]
copy
Download a file
$ b2 file download b2://[bucketName]/[fileName] [localFile]
copy
List buckets
$ b2 bucket list
copy
List files in a bucket
$ b2 ls --recursive b2://[bucketName]
copy
Sync a directory to a bucket
$ b2 sync [localPath] b2://[bucketName]/[path]
copy
Remove files matching a path
$ b2 rm --recursive b2://[bucketName]/[path]
copy

SYNOPSIS

b2 command [options]

DESCRIPTION

b2 is the command-line interface for Backblaze B2 Cloud Storage. It provides tools for uploading, downloading, and managing files in B2 buckets, offering S3-compatible object storage at lower costs.The tool supports large file uploads, versioning, and lifecycle rules. Version 4 reorganized commands into noun groups such as `b2 account`, `b2 bucket`, `b2 file`, and `b2 key`; older flat commands like `upload-file` and `list-buckets` are deprecated.

PARAMETERS

account authorize

Authenticate with an application key ID and key.
bucket create
Create a new bucket, for example `b2 bucket create [name] allPrivate`.
bucket list
List all buckets in the account.
file upload
Upload a single local file to a bucket.
file download
Download a file given a `b2://bucket/name` URI.
ls
List files in a bucket (use `--recursive` to descend).
rm
Remove files matching a `b2://` path.
sync
Synchronize a local directory and a bucket (one way).
key create
Create a scoped application key.
--threads num
Number of parallel threads for the operation.
--no-progress
Disable the progress display.

FEATURES

- Large file support (up to 10 TB)- File versioning- Server-side encryption- Lifecycle rules- S3-compatible API- Incremental sync

WORKFLOW

$ # Authorize
b2 account authorize <keyId> <key>

# Create bucket
b2 bucket create myBucket allPrivate

# Upload directory
b2 sync /local/path b2://myBucket/remote/path

# Download
b2 sync b2://myBucket/path /local/path
copy

INSTALL

brew install b2-tools
copy

CAVEATS

Requires application key with appropriate permissions. Downloads incur bandwidth costs. Deleted files may be retained (versioning). Class C transactions have fees. Sync operations can be slow on first run.

HISTORY

The B2 CLI was released by Backblaze around 2015 alongside the B2 Cloud Storage service as an affordable alternative to Amazon S3.

SEE ALSO

aws-s3(1), rclone(1), restic(1)

RESOURCES

Copied to clipboard
Kai