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 have been omitted.  The threads argument will need a recommended value between 1 and 99, with the default value being 10.

If you wish to see all of the options 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.

Note: If you need to find the names of your buckets, you can run the b2_list_buckets call: https://www.backblaze.com/b2/docs/b2_list_buckets.html

 

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 are 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

Article is closed for comments.
Powered by Zendesk