Backing up TrueNAS datasets with Backblaze
Are you tired of being limited by storage restrictions when backing up your TrueNAS datasets? One solution is to use Backblaze, a popular cloud storage provider. However, by using a personal version of Backblaze in combination with virtual drives, you can bypass these limitations and create unlimited backups of your important data. In this blog post, we will walk you through the process of setting up this backup solution, including creating a backup user in TrueNAS, setting permissions on the dataset, creating an SMB share, and mounting the share with Dokany. We will also show you how to create a scheduled task for automatic remounting and how to add the virtual drive to your Backblaze account. By following these steps, you can ensure that your data is safe and secure, even with large amounts of storage space needed.
1. Create backup user in TrueNAS
Create a new user in TrueNAS to use for backups. We can’t use the root user account, since it is not allowed to authenticate to SMB shares.
2. Set ACL on dataset to back up
We need to give our new backup user permission to access the dataset we want to back up.
- Select 3 dots on dataset and click
View Permissions
- Click
Edit permissions
in the top right corner of the new pane - Click
Set ACL
to open the ACL editor - Select the
POSIX_RESTRICTED
default ACL - Add a new item of type
mask
with read, write and execute permissions. The mask defines the maximum permissions users other than the owner of the dataset can have. - Add another item for the backup user. Set the type to
User
and enter the username. Set permissions to read, write and execute.
3. Create the SMB share
Go into shares in TrueNAS and create a new SMB share. Point it to the dataset you want to backup and give it a name.
4. Mount the SMB share with Dokany
We will mount the SMB share as a drive using the mirror
utility from Dokany
. This way Backblaze will think it is an actual hard drive and we will be able to back it up without storage limitations!
- Download the latest release of dokany from Github
- Install it while selecting all components
- Open PowerShell as Administrator and go into the directory where
mirror.exe
is located. For me it was inC:\Program Files\Dokan\DokanLibrary-2.0.6\sample\mirror\
- Test mount the SMB share as the
Z
drive using the following command:.\mirror.exe /r \\192.168.0.9\share /l z
- Verify the share was mounted with
ls Z:
or by browsing to it via the explorer
5. Create scheduled task to mount share on boot
Since we don’t want to have to manually remount the share each time the computer restarts, we will create a scheduled task to do it automatically.
- Press the Windows key and type
Task Scheduler
- Click on
Task Scheduler Library
- On the right, select
Create Task...
- In the
General
tab, select - a name
- Set
Run wether user is logged on or not
- Set
Run with highest privileges
- In
Triggers
tab, create a new trigger and selectAt startup
- In the
Actions
tab, create a new action - Set the action to
Start a program
- Set the program to the path of the
mirror.exe
binary, i.e.C:\Program Files\Dokan\DokanLibrary-2.0.6\sample\mirror\mirror.exe
- Set the arguments to
/r \\192.168.0.9\share /l z
- In the
Conditions
tab - Make sure both
Start the task only if computer is idle
andStop if computer ceases to be idle
are NOT selected - Deselected both options in the
Power
category as well - In the
Settings
tab - Select
Run task as soon as possible after a scheduled start is missed
- Set
If the task fails, restart
and set it to restart every minute for 60 times - Deselect
Stop the task if it runs longer than
6. Add new drive to Backblaze
We are basically finished now. Just restart the computer and the new drive should show up as expected. Now you simply need to add it in the settings in the Backblaze Control Panel.
In case Backblaze gives you an error about not being able to create a the .bzvol
folder on the drive, check your share permissions. If your permissions on the share are fine, check if the folder has been created already. If it has, just run chmod 777 .bzvol
on it and it should work.