Package: b2
B2 Command Line ToolThe command-line tool that gives easy access to all of the capabilities of B2 Cloud Storage.This program provides command-line access to the B2 service.DocumentationThe latest documentation is available onRead the Docs.InstallationFor detailed instructions on how to install the command line tool see ourquick start guide.HomebrewHomebrewis widely used in the Mac community, particularly amongst developers. We recommend using theB2 CLI Homebrewformula as the quickest setup method for Mac users:brewinstallb2-toolsBinariesStand-alone binaries are available for Linux and Windows; this is the most straightforward way to use the command-line tool and is sufficient in most use cases. The latest versions are available for download from theReleases page.Python Package IndexYou can also install it in your Python environment (virtualenvis recommended) from PyPI with:pipinstallb2[full]The extra dependencies improve debugging experience and, potentially, performance ofb2CLI, but are not strictly required.
You can install theb2without them:pipinstallb2DockerFor a truly platform independent solution, use the official docker image:dockerrunbackblazeit/b2:latest...See examples inUsage/Docker imageInstalling from sourceIf installing from the repository is needed in order to e.g. check if a pre-release version resolves a bug effectively, it can be installed with:python3setup.pyinstallIn this case of installing a pre-release,virtualenvis strongly recommended.Usageb2authorize-account[-h][applicationKeyId][applicationKey]b2cancel-all-unfinished-large-files[-h]bucketName
b2cancel-large-file[-h]fileId
b2clear-account[-h]b2copy-file-by-id[-h][--fetchMetadata][--contentTypeCONTENTTYPE][--rangeRANGE][--infoINFO|--noInfo][--destinationServerSideEncryption{SSE-B2,SSE-C}][--destinationServerSideEncryptionAlgorithm{AES256}][--sourceServerSideEncryption{SSE-C}][--sourceServerSideEncryptionAlgorithm{AES256}][--fileRetentionMode{compliance,governance}][--retainUntilTIMESTAMP][--legalHold{on,off}]sourceFileIddestinationBucketNameb2FileName
b2create-bucket[-h][--bucketInfoBUCKETINFO][--corsRulesCORSRULES][--fileLockEnabled][--replicationREPLICATION][--defaultServerSideEncryption{SSE-B2,none}][--defaultServerSideEncryptionAlgorithm{AES256}][--lifecycleRuleLIFECYCLERULES|--lifecycleRulesLIFECYCLERULES]bucketName{allPublic,allPrivate}b2create-key[-h][--bucketBUCKET][--namePrefixNAMEPREFIX][--durationDURATION][--allCapabilities]keyName[capabilities]b2delete-bucket[-h]bucketName
b2delete-file-version[-h][--bypassGovernance][fileName]fileId
b2delete-key[-h]applicationKeyId
b2download-file[-h][--threadsTHREADS][--max-download-streams-per-fileMAX_DOWNLOAD_STREAMS_PER_FILE][--noProgress][--sourceServerSideEncryption{SSE-C}][--sourceServerSideEncryptionAlgorithm{AES256}][--write-buffer-sizeBYTES][--skip-hash-verification]B2_URIlocalFileName
b2cat[-h][--noProgress][--sourceServerSideEncryption{SSE-C}][--sourceServerSideEncryptionAlgorithm{AES256}][--write-buffer-sizeBYTES][--skip-hash-verification]B2_URI
b2get-account-info[-h]b2get-bucket[-h][--showSize]bucketName
b2file-info[-h]B2_URI
b2get-download-auth[-h][--prefixPREFIX][--durationDURATION]bucketName
b2get-download-url-with-auth[-h][--durationDURATION]bucketNamefileName
b2hide-file[-h]bucketNamefileName
b2list-buckets[-h][--json]b2list-keys[-h][--long]b2list-parts[-h]largeFileId
b2list-unfinished-large-files[-h]bucketName
b2ls[-h][--long][--json][--replication][--versions][-r][--withWildcard]bucketName[folderName]b2rm[-h][--dryRun][--queueSizeQUEUESIZE][--noProgress][--failFast][--threadsTHREADS][--versions][-r][--withWildcard]bucketName[folderName]b2get-url[-h]B2_URI
b2sync[-h][--noProgress][--dryRun][--allowEmptySource][--excludeAllSymlinks][--syncThreadsSYNCTHREADS][--downloadThreadsDOWNLOADTHREADS][--uploadThreadsUPLOADTHREADS][--compareVersions{none,modTime,size}][--compareThresholdMILLIS][--excludeRegexREGEX][--includeRegexREGEX][--excludeDirRegexREGEX][--excludeIfModifiedAfterTIMESTAMP][--threadsTHREADS][--destinationServerSideEncryption{SSE-B2,SSE-C}][--destinationServerSideEncryptionAlgorithm{AES256}][--sourceServerSideEncryption{SSE-C}][--sourceServerSideEncryptionAlgorithm{AES256}][--write-buffer-sizeBYTES][--skip-hash-verification][--max-download-streams-per-fileMAX_DOWNLOAD_STREAMS_PER_FILE][--incrementalMode][--skipNewer|--replaceNewer][--delete|--keepDaysDAYS]sourcedestination
b2update-bucket[-h][--bucketInfoBUCKETINFO][--corsRulesCORSRULES][--defaultRetentionMode{compliance,governance,none}][--defaultRetentionPeriodperiod][--replicationREPLICATION][--fileLockEnabled][--defaultServerSideEncryption{SSE-B2,none}][--defaultServerSideEncryptionAlgorithm{AES256}][--lifecycleRuleLIFECYCLERULES|--lifecycleRulesLIFECYCLERULES]bucketName[{allPublic,allPrivate}]b2upload-file[-h][--contentTypeCONTENTTYPE][--sha1SHA1][--cache-controlCACHE_CONTROL][--infoINFO][--custom-upload-timestampCUSTOM_UPLOAD_TIMESTAMP][--minPartSizeMINPARTSIZE][--threadsTHREADS][--noProgress][--destinationServerSideEncryption{SSE-B2,SSE-C}][--destinationServerSideEncryptionAlgorithm{AES256}][--legalHold{on,off}][--fileRetentionMode{compliance,governance}][--retainUntilTIMESTAMP][--incrementalMode]bucketNamelocalFilePathb2FileName
b2upload-unbound-stream[-h][--partSizePARTSIZE][--unusedBufferTimeoutSecondsUNUSEDBUFFERTIMEOUTSECONDS][--contentTypeCONTENTTYPE][--sha1SHA1][--cache-controlCACHE_CONTROL][--infoINFO][--custom-upload-timestampCUSTOM_UPLOAD_TIMESTAMP][--minPartSizeMINPARTSIZE][--threadsTHREADS][--noProgress][--destinationServerSideEncryption{SSE-B2,SSE-C}][--destinationServerSideEncryptionAlgorithm{AES256}][--legalHold{on,off}][--fileRetentionMode{compliance,governance}][--retainUntilTIMESTAMP]bucketNamelocalFilePathb2FileName
b2update-file-legal-hold[-h][fileName]fileId{on,off}b2update-file-retention[-h][--retainUntilTIMESTAMP][--bypassGovernance][fileName]fileId{governance,compliance,none}b2replication-setup[-h][--destination-profileDESTINATION_PROFILE][--nameNAME][--priorityPRIORITY][--file-name-prefixPREFIX][--include-existing-files]SOURCE_BUCKET_NAMEDESTINATION_BUCKET_NAME
b2replication-delete[-h]SOURCE_BUCKET_NAMEREPLICATION_RULE_NAME
b2replication-pause[-h]SOURCE_BUCKET_NAMEREPLICATION_RULE_NAME
b2replication-unpause[-h]SOURCE_BUCKET_NAMEREPLICATION_RULE_NAME
b2replication-status[-h][--ruleREPLICATION_RULE_NAME][--destination-profileDESTINATION_PROFILE][--dont-scan-destination][--output-format{console,json,csv}][--noProgress][--columnsCOLUMNONE,COLUMNTWO]SOURCE_BUCKET_NAME
b2version[-h][--short]b2license[-h]b2install-autocomplete[-h][--shell{bash}]The environment variableB2_ACCOUNT_INFOspecifies the SQLite
file to use for caching authentication information.
The default file to use is:~/.b2_account_info.To get more details on a specific command useb2 <command> --help.When authorizing with application keys, this tool requires that the key
have thelistBucketscapability so that it can take the bucket names
you provide on the command line and translate them into bucket IDs for the
B2 Storage service.  Each different command may required additional
capabilities. You can find the details for each command in the help for
that command.Parallelism and the--threadsparameterUsers with high performance networks, file sets with very small files, or high network latency, will usually benefit from increased parallelism. Experiment with using the--threadsparameter to increase performance.Note that using many threads could in some cases be detrimental to the other users on your network.Docker imageAuthorizationUser can either authorize on each command (list-bucketsis just a example here)B2_APPLICATION_KEY=<key>B2_APPLICATION_KEY_ID=<key-id>dockerrun--rm-eB2_APPLICATION_KEY-eB2_APPLICATION_KEY_IDbackblazeit/b2:latestlist-bucketsor authorize once and keep the credentials persisted:dockerrun--rm-it-vb2:/rootbackblazeit/b2:latestauthorize-account
dockerrun--rm-vb2:/rootbackblazeit/b2:latestlist-buckets# remember to include `-v` - authorization details are thereDownloading and uploadingWhen uploading a single file, data can be passed to the container via a pipe:catsource_file.txt|dockerrun-i--rm-vb2:/rootbackblazeit/b2:latestupload-unbound-streambucket_name-target_file_nameor by mounting local files in the docker container:dockerrun--rm-vb2:/root-v/home/user/path/to/data:/databackblazeit/b2:latestupload-filebucket_name/data/source_file.txttarget_file_nameVersionsWhen you start working withb2, you might notice that more than one script is available to you.
This is by design - we use theApiVermethodology to provide all the commands to all the versions
while also providing all the bugfixes to all the old versions.If you use theb2command, you're working with the latest stable version.
It provides all the bells and whistles, latest features, and the best performance.
While it's a great version to work with, if you're willing to write a reliable, long-running script,
you might find out that after some time it will break.
New commands will appear, older will deprecate and be removed, parameters will change.
Backblaze service evolves and theb2CLI evolves with it.However, now you have a way around this problem.
Instead of using theb2command, you can use a version-bound interface e.g.:b2v3.
This command will always provide the same interface that theApiVerversion3provided.
Even if theb2command goes into theApiVerversion4,6or even10with some major changes,b2v3will still provide the same interface, same commands, and same parameters.
Over time, it might get slower as we may need to emulate some older behaviors, but we'll ensure that it won't break.ContribDetailed logsVerbose logs to stdout can be enabled with the--verboseflag.A hidden flag--debugLogscan be used to enable logging to ab2_cli.logfile (with log rotation at midnight) in current working directory. Please pay attention not to launch the tool from the directory that you are syncing, or the logs will get synced to the remote server (unless that is really what you want to achieve).For advanced users, a hidden option--logConfig <filename.ini>can be used to enable logging in a user-defined format and verbosity. Check out theexample log configuration.In order to see the raw request headers you mayexport B2_DEBUG_HTTP=1before calling the CLI.Release HistoryPlease refer to thechangelog.Developer InfoPlease see ourcontributing guidelines.