Using B2’s S3 endpoints you are able to use AWS CLI to communicate and update your B2 buckets. Once configured you can use this tool to transfer data between and S3 bucket and B2.
Start by installing AWS CLI. You can do this by following the instructions here.
Confirm that it is installed by using aws --version.
Configuring AWS CLI to interface with your B2 account:
Use the command aws configure to start the configuration process.
You will be prompted with the following. You can find information highlighted in red by creating keys in the “App Key” section of your Backblaze account.
AWS Access Key ID [None]: keyID
AWS Secret Access Key [None]: applicationKey
Default region name [None]: leave blank
Default output format [None]: leave blank
Configuration should be set now. You should be able to test the integration by attempting to list buckets on your account.
aws s3 ls --endpoint-url=<S3 Endpoint URL>
Using AWS CLI to transfer data to B2
Step 1 (Optional):
If data is coming from an AWS S3 Bucket, you will first need to add your S3 buckets using the configuration tool.
Then you will need to copy files to a local directory using the command:
aws s3 cp s3://<source_bucket>/ <local_directory> --recursive
Now you can transfer files directly to B2 using the command:
aws s3 cp <local_directory>/ s3://<destination_bucket>/ --recursive --endpoint-url=<S3 Endpoint URL>
Creating presigned URLs from AWS CLI
Generating a presigned URL on a bucket that expires in 3600 seconds (default)
aws s3 presign s3://<destination_bucket>/ --endpoint-url=<S3 Endpoint URL>
Generating a presigned URL on a folder in a bucket, that expires in 360 seconds
aws s3 presign s3://<destination_bucket>/<folder>/<object-name> --expires-in 300 --endpoint-url=<S3 Endpoint URL>
aws s3 presign s3://allgroups/mygroup/ --expires-in 300 --endpoint-url=https://s3.us-west-002.backblazeb2.com
Note: Depending on how you are using the presigned URL, you may need to enclose it in quotes.
The S3 Compatible API for Backblaze B2 Cloud Storage allows 1000’s of integrations to work with B2 natively. If you’re new to the S3 Compatible API, please see our Getting Started Guide. If you have any trouble using the AWS CLI with B2, please let us know by emailing us at firstname.lastname@example.org