I recently set off to find a cheap (and hopefully free) cloud backup solution for some crucial files in my home infrastructure. I stumbled upon Backblaze’s B2 object storage solution (similar to Amazon S3 or Azure Blob). Backblaze is pretty awesome, and provides up to 10GB free storage across multiple buckets to try it out!
Β
Requirements
- A Linux machine (virtual, container, or bare metal)
- Super sudoer powers
- A Backblaze account
Β
Β
π§ Prepare Linux
β¬οΈ Make sure you have the latest updates
|
|
β¨ Install curl
(if not already)
|
|
β¨ Install Rclone
Rclone is a tool written in Go that allows the movement of files between local and remote directories. It can be installed by following the tutorial on their docs.
To check if Rclone
is installed properly, just type rclone
in your CLI. As long as you don’t get the “Unrecognized command” error, you’re good!
Β
π₯ Prepare Backblaze
Make sure you have a Backblaze account created, and log in.
πͺ£ Create a Bucket
- Make sure you are in your buckets list
- Create a bucket
- Give it a unique name
- Private
- Encryption disabled
- Object lock disabled
- Click create
π Create App key
- Click
App keys
on the left - Scroll down, click
Add a New Application Key
- Give it a friendly name
- If you want to restrict the key to a specific bucket, choose it from the dropdown
- Keep it set to read/write
- Click create
- Make sure to save the
keyID
andapplicationKey
for later
Β
ποΈ Set up Rclone
In Linux, enter the command rclone config
Type
n
for a new remoteGive it a name (such as backblaze-bucketname)
This will list a bunch of supported remotes, find
Backblaze B2
in the list, and enter the corresponding number into the promptFor
Account
, use thekeyID
received from generating the App keyFor
Key
, use the `applicationKey1 received from generating the App keySet the following values as you see fit. The defaults should be good for most cases.
Once the list of current remotes shows, you can quit the config CLI with
q
Remotes can be checked by using
rclone listremotes
- This will return a list of all of your remotes
Β
π Copy a file (or directory) to your B2 bucket
The proper syntax to copy a file is
|
|
cd
into a directory that contains the file you want to copy up. Let’s say this file is namedfile.txt
- Use
rclone copy
to copy up the file- Keep in mind, my remote’s name is
backblaze-testing
and my bucket’s name isquib-testing
- Keep in mind, my remote’s name is
|
|
- For a directory, this is very similar. Let’s say this directory is named
directory/
|
|
If this was successful, nothing is returned.
Β
β Check if your file is uploaded
Back in Backblaze, click Browse Files
, and select the bucket you would like to browse.
If the file uploaded properly, it should show up there!
Β
βΎοΈ Automate it
Now, you’re probably here because you want to automate this. To do so, you’ll need to create a cron job for each backup interval you want.
To edit cron tasks:
|
|
- And select your desired text editor
- Cron jobs are formatted by the desired time interval, followed by the command to run
- Ex.
* * * * * /home/user/script.sh
will run the file/home/user/script.sh
every minute- You can generate times to your liking easily with this website
Example cron job:
|
|