Download Snapshots or large files from B2

Large files can be difficult to retrieve via https and other single click download methods.

If you have a large file or snapshot that is multiple GB or even in the TB, you can utilize the b2 command line tool to utilize the sync function to download data.

To use this you will need to install the Bs command line interface, information for this is here:

https://www.backblaze.com/b2/docs/quick_command_line.html

Once the B2 CLI (Command Line Interface) is installed you can run the b2 sync command to download data.

The syntax is here:

b2 sync [--threads N] <source> <destination>

In our case for downloading data however we will be utilizing the --threads argument and the other options for the command has been omitted.  The threads argument will need a value between 1 and 50.

If you wish to see all of the option for the command b2 sync, then at the command line, type in:

b2 sync

Downloading the files from a bucket

To download all the files from a bucket or snapshot, you will do the following:

b2 sync --threads 10 b2://MyBucket .

This command would look for all files in the b2 bucket: MyBucket and then download all of the files, to the current working directory of the command line interface.

If you wanted to designate a location, like a Music folder, then you use a command that looked like this:

b2 sync --threads --25 b2://MyBucket "C:\Users\testuser\Music"

This would use 25 threads to transfer all of the data from the bucket: MyBucket to the Users Music folder.

On a mac this would be the equivalent command:

b2 sync --threads 25 b2://MyBucket "/Users/testuser/Music"

This will allow you bolster your download speed with the addition of multiple threads.

Downloading a single large file

To download a single file from a bucket you will need to add the argument [--includeRegex <regex>] and [--includeRegex <regex>] as well.

Scenario:

You have a large image file in a bucket, but there is 700,000 files in the bucket and you do not want to download all of the data and just one file that is name test/TestEnvironment.img.

The command to download the file would be as follows:

b2 sync --threads 30 --includeRegex test\/TestEnvironment.img --excludeRegex "." b2://MyBucket "/Users/testuser/Images"

The --excludeRegex "." is a wildcard. So this command will exclude everything except the file that is included.

 

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk