Backing up files is arguably one of the most important things someone can do on their computer. Ensuring there is a copy of your most important data affords you the ability to not worry about a future ransomware virus, a stolen/broken computer, or just a simple accident that could erase your information forever.
A strategy that is widely seen as a very effective way to backup your data is the 3-2-1 Backup Rules/Best Practices:
With the following guide, I hope to be able to have an additional copy of my data, stored on a different storage type, and synced with a cloud service provider - Backblaze in this case.
Preparing the Hardware (optional)
If you already have a computer setup, please skip this step. If not, see the list of hardware I used for this project - found below:
- Raspberry Pi 3 Model B
- Raspberry PI Case
- SD Card
- Internal Hard Drive
- External Hard Drive Enclosure
Note: If you do not have an extra hard drive sitting around, you can purchase external drive instead.
Preparing the Computer
The only prerequisite for the computer is that you have Windows, macOS, or Linux installed and functioning. Plug in your external hard drive and make sure that it is functioning correctly. Additionally, ensure that you have an active internet connection as that will be required for installing the necessary software and uploading your files to Backblaze B2 for backup.
Backing up Your Files
Step 1 - Set Up a Backblaze B2 Account
While Rclone supports many different cloud providers (see their website here), I will be using B2 from Backblaze. Follow the instructions on the B2 website to setup your B2 account and get your API key - this key will allow you to access you B2 account through Rclone.
Step 2 - Install Rclone
Rclone will need to be installed on the computer you are using to store your files. If you are not using the same hardware I am, please install the Rclone version that will work for your computer. Visit the Rclone downloads page to find the installer for your computer. If you are following my hardware choice, select the ARM - 32 Bit installer. Finally, follow the installation instructions on the Rclone website to properly install Rclone on your computer.
Step 3 - Connect Rclone to Backblaze B2
nto create a new remote.
- Specify a name to reference this remote in commands. For my purposes, I chose
enterto select Backblaze B2.
- Enter your Backblaze Account ID then hit
enter. This will look something like
- Enter your Backblaze Application Key then hit
enter. This will look something like
- Leave Endpoint blank then hit
enterto save configuration.
For more information, please visit the Rclone B2 website.
Step 4 - Configure Encryption in Rclone
nto create an encrypted container.
- Specify a name to reference this container in commands. For my purposes, I chose
enterto select crypt.
enterto select the previously made remote. For my purpose, this is
backupis the name of my B2 bucket.
standardfor encrypted file names.
- Choose a passphrase or generate one. It is important that you remember your passphrase - you will not be able to decrypt your backups without it.
- Choose a salt or generate one. It is important that you remember your salt - you will not be able to decrypt your backups without it.
yto confirm the configuration and press
qto close Rclone.
Step 5 - Backing up Your Files
Now, when wanting to backup a folder to BackBlaze, type the following command:
rclone sync /path/to/folder secret:
This line takes all of your files in the folder path and uploads them to your Backblaze B2 bucket. For me, I write the following line:
rclone sync Backup/ secret
Note: There are two options for uploading to the cloud. While I use
sync, you can also use
copy. Here are the differences:
Syncwill mirror the folder path exactly from your local filesystem to Backblaze. This deletes files in the destination that have been removed from the source.
Copywill copy files from your local filesystem to Backblaze where deleted files will NOT be deleted from Backblaze.
If you have a lot of files to upload that could take a long time, use the following command so that output is recorded to a file and the upload will not get killed if you log out:
setsid [command] --log-file /path/to/file.log &>/dev/null
[command] is the command you used above.
Step 6 - Backup Automation
The following set of commands will setup your computer to run an automatic backup of your files.
- At the end of the file, add the following command:
0 * * * * /usr/bin/setsid /usr/sbin/rclone sync /path/to/folder secret: &>/dev/null
- Save and exit your crontab file.
Note: You can add an output log file by using the
--log-file parameter found in step 5. Additionally, you can also choose between the
copy rclone modes.
Step 7 - Restoring Your Files
To obtain you files from Backblaze, you will need to configure rclone on a new machine or you will need to move to a different location of your uploading computer. It can be helpful to backup you configuration files to make it easier to restore. Once your configuration is correct, run the following command:
rclone sync secret: /path/to/folder
Your files are now being securely backed up to the cloud!