b2
Manage Backblaze B2 cloud storage files
TLDR
Access your account
List the existing buckets in your account
Create a bucket, provide the bucket name, and access type (e.g. allPublic or allPrivate)
Upload a file. Choose a file, bucket, and a folder
Upload a source directory to a Backblaze B2 bucket destination
Copy a file from one bucket to another bucket
Show the files in your bucket
Remove a "folder" or a set of files matching a pattern
SYNOPSIS
b2 [global-options] subcommand [subcommand-options] [arguments]
Examples:
b2 authorize-account [options]
b2 upload-file <bucket> <local-path> <b2-path>
b2 ls [bucket]
PARAMETERS
--version
Show program's version number and exit
-h, --help
Show help message and exit
--debug
Print debug information to stderr
--log-level LEVEL
Set log level: DEBUG, INFO, WARNING, ERROR, CRITICAL
--no-color
Disable colored terminal output
--user-agent-suffix SUFFIX
Append string to user-agent header
--authorization ACCOUNT_AUTH
Provide base64 authorization token directly
DESCRIPTION
The b2 command-line tool provides a powerful interface to Backblaze B2 Cloud Storage, an affordable S3-compatible object storage service. It enables seamless file management operations including uploading, downloading, listing, deleting, and sharing files and buckets directly from the Linux terminal.
Key capabilities include multipart uploads for large files (>5GB recommended), resumable transfers, server-side encryption support, bucket lifecycle policies, and CORS configuration. Users authenticate once via application keys, after which the tool caches credentials for subsequent operations. It integrates well with shell scripts, supports progress indicators, and handles versioning and legal holds.
Developed in Python, b2 is open-source, cross-platform, and extensible. Ideal for backups, media serving, and data archiving, it offers cost-effective storage without vendor lock-in. Installation is straightforward via pip install b2 or package managers. Common workflows involve authorizing an account, creating buckets, and syncing data with local directories.
With robust error handling and logging, it's suitable for both interactive use and automation in cron jobs or CI/CD pipelines. Compared to GUI tools, it excels in efficiency for bulk operations.
CAVEATS
Requires initial setup with b2 authorize-account using Backblaze application key; credentials cached in ~/.b2_account. Not installed by default on Linux distributions. Large uploads need sufficient bandwidth; multipart threshold configurable per subcommand. API calls incur B2 usage fees.
INSTALLATION
pip install b2 or pipx install b2; binaries available on GitHub releases for standalone use.
Apt/brew support via third-party repos.
COMMON SUBCOMMANDS
authorize-account: Authenticate.
upload-file: Upload local files.
download-file-by-name: Download by path.
ls: List buckets/files.
rm: Delete files.
sync: Mirror directories.
Run b2 --help for full list.
EXAMPLE
b2 authorize-account KEYID APPLICATIONKEY
b2 create-bucket mybackup shared
b2 upload-file mybackup ./data.tar.gz b2://mybackup/data.tar.gz
HISTORY
Released by Backblaze in 2016 as open-source Python CLI (MIT license). Actively maintained on GitHub with regular updates for new B2 features like Object Lock and legal holds. Widely adopted for cost-effective backups since B2's 2015 launch.


