LinuxCommandLibrary

b2-tools

Manage Backblaze B2 Cloud Storage

TLDR

Access your account

$ b2 authorize_account [key_id]
copy

List the existing buckets in your account
$ b2 list_buckets
copy

Create a bucket, provide the bucket name, and access type (e.g. allPublic or allPrivate)
$ b2 create_bucket [bucket_name] [allPublic|allPrivate]
copy

Upload a file. Choose a file, bucket, and a folder
$ b2 upload_file [bucket_name] [path/to/file] [folder_name]
copy

Upload a source directory to a Backblaze B2 bucket destination
$ b2 sync [path/to/source_file] [bucket_name]
copy

Copy a file from one bucket to another bucket
$ b2 copy-file-by-id [path/to/source_file_id] [destination_bucket_name] [path/to/b2_file]
copy

Show the files in your bucket
$ b2 ls [bucket_name]
copy

Remove a "folder" or a set of files matching a pattern
$ b2 rm [path/to/folder|pattern]
copy

SYNOPSIS

b2 [global-options] <subcommand> [<args>]

PARAMETERS

-h, --help
    Show help message and exit

--version
    Show program's version and exit

--debug={0,1,2,3}
    Set debug verbosity level (0=off, 3=max)

--log-level={debug,info,warning,error,critical}
    Set logging level

--application-key-id ID
    Override cached key ID for auth

--application-key KEY
    Override cached application key

DESCRIPTION

b2-tools installs the b2 command, a versatile Python-based CLI for managing Backblaze B2 object storage. It supports full bucket and file operations: create/delete buckets, upload/download files (including large files via multipart chunking), list contents, delete files/buckets, set lifecycle rules, manage file versions, ACLs, and server-side encryption.

Authentication uses application keys via b2 authorize_account, caching credentials locally for reuse. Ideal for backups, syncing, and automation, it integrates with pipes for streaming, offers progress bars, dry-run modes, threading for parallel transfers, and configurable retries for reliability.

Handles B2-specific features like hide/unhide files, copy within B2, and large-file ID retrieval. Logging levels aid debugging. Cross-platform, but requires Python 3.5+. Widely used in scripts with tools like restic or duplicity.

CAVEATS

Requires prior b2 authorize_account for auth cache.
Rate-limited by B2 API; use --threads wisely.
Not for interactive use; scripting-focused.

INSTALLATION

pip install b2 or apt install b2-tools (Debian/Ubuntu). Requires Python 3.5+.

KEY SUBCOMMANDS

authorize_account, upload_file, download_file, ls, rm, cp, sync, bucket create.

HISTORY

Released by Backblaze in 2016 as open-source CLI. Actively maintained on GitHub/backblaze/b2-cli; evolved from internal tools to support all B2 v2 API features.

SEE ALSO

rclone(1), restic(1), duplicity(1), aws(1)

Copied to clipboard