Audrey M. Roy Greenfeld

Quietly building the future.

Recursively Copy Files to Backblaze B2

2024-06-05

B2 Command Line Tool

I first installed this via brew install b2-tools. Then I uninstalled that and decided to use rye add b2to make installation easier for project collaborators.

To recursively copy files from a local directory to a Backblaze B2 bucket using the b2 command line tool:

$ b2 account authorize
Backblaze application key ID: <copy and paste your application key ID>
Backblaze application key: <copy and paste your application key>
$ b2 sync --replaceNewer /path/to/local/directory b2://bucket-name

For example, if you have a git repo with an images directory and you want to copy it to an images directory in a B2 bucket called my-bucket, you would run:

$ cd my-repo
$ b2 sync --replaceNewer images b2://my-bucket/images

Rclone

To do the same with rclone:

rclone copy /path/to/local/directory b2:bucket-name

You can also use the --progress flag to show the progress of the copy operation:

rclone copy /path/to/local/directory b2:bucket-name --progress

This will display a progress bar showing the percentage of files copied and the transfer speed.

If you want to copy only new or modified files, you can use the --update flag:

rclone copy /path/to/local/directory b2:bucket-name --update