How to Backup File to Backblaze Bucket with Bash

Introduction

Backblaze is an object storage service that provides a cost-effective solution to store your data in a safe and secure location. It is a simple, easy-to-use, and alternative solution to AWS S3. Backblaze offers simple, affordable, and predictable pricing. Storage is $0.005/GB/Month, with download costs of $0.01/GB.

SnapShooter allows you to backup files and directories to Backblaze easily. SnapShooter comes with a simple and user-friendly control panel that helps beginners to control and manage their backups.

This post will show you how to backup files to Backblaze Bucket manually and using SnapShooter.

Create your Backblaze Bucket

First, you will need to create a new bucket on the Backblaze website. Follow the below steps to create a new bucket on the Backblaze:

Step 1 - Sign in to your Backblaze account and go to the Bucket page to create a new Bucket.

Step 2 - Click on the Create a Bucket button. You should see the following page:

Step 3 - Click on the Create a Bucket button. Once the Bucket is created, you should see the following page:

Note down the Backblaze Bucket URL from the above image. You will need it later in this article.

Create Your Backblaze Credentials

In order to create backups with Backblaze, you will need to create the credentials to connect it from the remote server.

Step 1 - On the Backblaze dashboard, click on the "App Keys" in the left pane as shown below:

Step 2 - Now, click on "Add a new Application Key" button. You should see the following page:

Step 3 - Provide all required details and click on the Create New Key button. You should see the following page:

Note down the keyID, and applicationKey from the above image. You will need both to integrate Backblaze with the application.

Backup File to Backblaze Bucket Manually

In this section, we will show you how to back up a file from your server to the Backblaze Bucket using the S3cmd tool.

Install S3cmd

Before starting, you will need to install the S3cmd tool on the server from where you want to back up your file.

S3cmd is a free and open-source command-line tool that allows you to upload, download and manage data in Backblaze Bucket and other cloud storage service providers. Follow the below steps to install the S3cmd to your server.

First, install the Python and other dependencies by running the following command:

apt-get install python3 python3-setuptools curl -y

Next, download the latest version of S3cmd using the following command:

curl -LO https://github.com/s3tools/s3cmd/releases/download/v2.2.0/s3cmd-2.2.0.tar.gz

Next, extract the downloaded file with the following command:

tar -xvzf s3cmd-2.2.0.tar.gz

Next, navigate to the extracted directory and install it using the following command:

cd s3cmd-2.2.0
python3 setup.py install

Once the S3cmd is installed, verify the S3cmd version using the following command:

s3cmd --version

You will get the following output:

s3cmd version 2.2.0

Configure S3cmd to Connect Backblaze

Next, you will need to configure the S3cmd using the Backblaze Access key and Secret key. You can configure it using the following command:

s3cmd --configure

You will be asked to provide your Backblaze Access Key, Secret Key, Region, and Endpoint as shown below:

Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.
 
Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.
Access Key: 004d55130756c060000000005
Secret Key: K0043tUBBzBKAMaXEKHvSopk1QYrrRc
Default Region [US]: us-west-004
 
Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.
S3 Endpoint [s3.amazonaws.com]: s3.us-west-004.backblazeb2.com
 
Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used
if the target S3 system supports dns based buckets.
DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: %(bucket)s.s3.us-west-004.backblazeb2.com
 
Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password:
Path to GPG program [/usr/bin/gpg]:
 
When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP, and can only be proxied with Python 2.7 or newer
Use HTTPS protocol [Yes]:
 
On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can't connect to S3 directly
HTTP Proxy server name:
 
New settings:
Access Key: 004d55130756c060000000005
Secret Key: K0043tUBBzBKAMaXEKHvSopk1QYrrRc
Default Region: us-west-004
S3 Endpoint: s3.us-west-004.backblazeb2.com
DNS-style bucket+hostname:port template for accessing a bucket: %(bucket)s.s3.us-west-004.backblazeb2.com
Encryption password:
Path to GPG program: /usr/bin/gpg
Use HTTPS protocol: True
HTTP Proxy server name:
HTTP Proxy server port: 0
 
Test access with supplied credentials? [Y/n] Y
Please wait, attempting to list all buckets...
Success. Your access key and secret key worked fine :-)
 
Now verifying that encryption works...
Not configured. Never mind.
 
Save settings? [y/N] y
Configuration saved to '/root/.s3cfg'
 
 
Once the S3cmd is configured, you can verify your Bucket information using the following command:
 
s3cmd info s3://snapshooter-file-backup/
 
You will get the following output:
 
s3://snapshooter-file-backup/ (bucket):
Location: us-west-004
Payer: none
Expiration Rule: none
Policy: none
CORS: none
ACL: d55130756c06: FULL_CONTROL

Use S3cmd to Backup File to Backblaze Bucket

At this point, S3cmd is installed and configured to manage the Backblaze Bucket. You can now able to copy files or directory using S3cmd.

To copy a file named backup.tar.gz to the Backblaze Bucket, run the following command:

s3cmd put backup.tar.gz s3://snapshooter-file-backup/

Output:

upload: 'backup.tar.gz' -> 's3://snapshooter-file-backup/backup.tar.gz' [1 of 1]
10485760 of 10485760 100% in 0s 12.25 MB/s done

To copy the directory named /etc, compress it and copy it to the Backblaze Bucket, run the following command:

tar -czf - /etc | s3cmd put - s3://snapshooter-file-backup/etc_backup.tar.gz

Output:

upload: '<stdin>' -> 's3://snapshooter-file-backup/etc_backup.tar.gz' [part 1 of -, 373KB] [1 of 1]
382870 of 382870 100% in 0s 1283.47 KB/s done

You can now verify all files on the Backblaze Bucket using the following command:

s3cmd ls s3://snapshooter-file-backup/

You will get the following output:

2022-03-29 04:38 10485760 s3://snapshooter-file-backup/backup.tar.gz
2022-03-29 04:38 382870 s3://snapshooter-file-backup/etc_backup.tar.gz

You can also log in to the Backblaze and verify your backup files as shown below:

Scheduled Server File Backups SnapShooter

Server File Backup to your external storage

Learn more about Server File Backups

Get started for free
No credit card required. Cancel anytime!

Conclusion

In this guide, you learned how to backup files to Backblaze using SnapShooter. You can now manage and control all your backup from the centralized location.

Was this page helpful?

Thank you for helping us improve!