Resource icon

How to: Backup to local disks

Jatrabari

Contributor
Joined
Sep 23, 2017
Messages
100
I've been super happy with the system-great for off-site backups and keeping a backup that is safe from catastrophic events such as a lightening strike on the power line or power supply failing and frying the whole system. Very easy to use:
  1. Just slide the cartridge in, turn the key and the drive powers up.
  2. Wait for the drive to spin up and be recognized by FreeNAS.
  3. Sign in to the GUI and import the drive (pool) or if it's the first time with a new disk create your pool.
  4. Run your backup.
  5. Log into the GUI again and detach the drive.
  6. Once detached, turn the key, and the drive powers off - wait a few seconds for the drive to spin down and park (to be on the safe side).
  7. Pull out the cartridge and store the drive safely.

(For the benefit of fellow Canadians (Americans can easily get it directly from Addonics and possibly other major suppliers) the most affordable way to get this in Canada (Summer 2017) is from NCIX, but it was not on the NCIX web site. I had to contact NCIX and arrange a special order, and I also had to contact Addonics to contact NCIX to advise them of the availability of the Drive Cady: Part DSACSB)-NCIX orignally told me it was unavailable. The only delivery method offered by Addonics for international orders was courier and the brokerage fees for customs clearance were outrageous. It was cheaper to have NCIX import to Vancouver and then ship to me customs cleared in the Toronto area.)

I hope this helps others looking for a simple backup system for home/small office use where a second system for replication is not practical, and that it will save other from wasting all the time that I had to waste to find and acquire this solution.

@NASbox How is your procedure doing? Are you using Arwen's script or something own? When do you do scrubs and SMART tests for the removable drive(s)?
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
I am planning to implement finally a local disk replication. Is this script still viable to use? What about zfs send receive and/or straight GUI replication task?
The script is intended to be an example. And yes, it does work. In theory you can change the script to use ZFS send & receive. As for GUI replication task(s), I don't know.

At the time I wrote this resource, there were a few posts asking about local disk backups, but no clear answers. Since I was using local disk backups and it worked for me, I described what I did.

Everyone's backup solution is based on the user's own needs, just like their NAS solution. If mine is not suitable, use what parts do seem suitable. My suggestion is to manually run through the procedure, (multiple times if need be), document the procedure, even if it's just a simple text file. Then you can automate pieces or the whole thing.

Good luck.
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
I've found the only high quality, external enclosure that has the connections I need, (eSATA & USB3). It's expensive, quite heavy, but seems like a solid device that would last 5 to 10 years. Plus, it has a fan for those disks that run warm or hot. Here is a link;

Cru-dataport LLC Rtx110-3q, All-Metal 1-Bay Trayfree Drive Enclosure, USB3/eSATA/FW800

So far, it's been working great. Even when I had an emergency restore. My Media server does not have redundancy on the Media, (it's 1.7TBs). This is why I like ZFS. It found 3 files with errors, and I was able to restore them from backups. This allows me to have confidence that no-redundancy Media, with multiple backups, is a good solution.

My laptops and Media server only have USB3 ports. My new desktop & FreeNAS have eSATA ports. So I wanted a device with both.
 
Last edited:

Michael Wenyon

Dabbler
Joined
Jan 3, 2016
Messages
23
I had success with the Startech S351BMU33ET single-drive enclosure over eSATA. It also has USB3.0 connections.

I was able to run and read SMART tests on the disk.
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611

dcs730

Dabbler
Joined
Jun 26, 2021
Messages
22
Hi all - Not sure how relevant this local backup script is with TrusNAS Core 12.0-U6.

I would like to implement a more automated backup for some rotating USB External HDDs to backup the DATA pool.

My objectives / Questions

1. Use the existing usb disks I have to backup a subset1 and subset2 of data from the DATA pool.
2. Rotate them weekly for offsite storage.
3. Use the 2x 3Tb Disks for Subset1 of DATA
4. Use the 2x 2Tb Disks for Subset2 of DATA
5. If possible, would like the ability to plug these disks directly into a Windows PC to access the data backups.
6. Can I modify any of the below (in my post) to the suit anything listed in this post? https://forums.freenas.org/index.php?resources/how-to-backup-to-local-disks.26/
7. Any improvements or recommendations welcome.
8. Is there a package that can be installed in TrueNAS (Similar to HyperBackup in a SynologyNAS) that can perform the backups to external disks?

* My TrueNAS Implementation *
TrueNAS is setup with a single Pool - DATA of 4x6Tb (RAIDZ2) - provides a total of just over 10Tb of storage.
4.38 TiB is in use.

Breakdown as follows:

1637132276291.png


* My External Backup Disks *
2x 3Tb External USB3 SATA Disks
2x 2Tb External USB3 SATA Disks

I already have these disks - They are currently formatted as NTFS.
They can be formatted to another type if required.

*********************
** My Current Soln **

I have been mounting the external USB HDDs using the kldload fuse command from a terminal window,
then running a rsync command to copy the data from the relevant folders to the external disks.

It does work with mixed results and requires lots of manual intervention and checking.
It's not 100% successful and reliable.

I have tried a SHELL script and starting them in CRON JOBS in the GUI and have mixed results.
So I have to revert to running them manaully - NOT IDEAL from Terminal Window.

Some details WRT the current solution as follows...

******************************************
Plug in external USB3 HDD - NTFS Formatted

In Storage - Disks - Should show DA0 (Or similar) - once external USB Disk is connected.

Disk - DA0

-- In TrueNAS GUI --
Go to Disks - This will show the dev number - eg "da0"

Open a terminal session
gpart show -p /dev/da0

This command above will show the partition on the external disk to mount below.

The output shows : /dev/da0p1

**
From shell cmd prompt

kldload fuse
cd ..
cd /mnt
mkdir ntfs

Then follow below.

Then open shell prompt on TrueNAS
kldload fuse
ntfs-3g /dev/da0p1 /mnt/ntfs (Where da0 = disk number and p? = the partition to be mounted)
rsync -avhP /mnt/DATA /mnt/ntfs This is the rsync source and dest locations (Data copy)
umount /mnt/ntfs Disconnect disk and store offsite

THE BELOW APPEARS TO WORK WELL - When run manually from a terminal shell command

*************************************************************

# Backup Subset1 ** MEDIA DATA TO OFFSITE 3 Tb USB DISK **
# Subset1 approx 2.69 Tb (Should copy across to 3 Tb Disks)
cd ..
cd /
kldload fuse
cd mnt
mkdir ntfs
ntfs-3g /dev/da0p1 /mnt/ntfs
rsync -avhP --delete-before /mnt/DATA/PlexMedia/Movies /mnt/ntfs/DATA
rsync -avhP --delete-before /mnt/DATA/DATASTORE /mnt/ntfs/DATA
umount /mnt/ntfs

**************************************************************

# Backup Subset2 ** WORK DATA TO OFFSITE HP DISKS **
# Subset2 approx 1.66Tb (Should copy across to 2Tb Disks)
kldload fuse
cd ..
cd mnt
mkdir ntfs1
ntfs-3g /dev/da0s1 /mnt/ntfs1
rsync -avhP --delete-before /mnt/DATA/Scans /mnt/ntfs1/DATA
rsync -avhP --delete-before /mnt/DATA/DCS /mnt/ntfs1/DATA
rsync -avhP --delete-before /mnt/DATA/Shared /mnt/ntfs1/DATA
rsync -avhP --delete-before /mnt/DATA/FileCentre /mnt/ntfs1/DATA
rsync -avhP --delete-before /mnt/DATA/Software /mnt/ntfs1/DATA
rsync -avhP --delete-before /mnt/DATA/UserData /mnt/ntfs1/DATA
rsync -avhP --delete-before /mnt/DATA/VMs /mnt/ntfs1/DATA
rsync -avhP --delete-before /mnt/DATA/PlexMedia/Music /mnt/ntfs1/DATA
rsync -avhP --delete-before /mnt/DATA/PlexMedia/TV /mnt/ntfs1/DATA
rsync -avhP --delete-before /mnt/DATA/PlexMedia/Photos /mnt/ntfs1/DATA
rsync -avhP --delete-before /mnt/DATA/PlexMedia/Videos /mnt/ntfs1/DATA
umount /mnt/ntfs1

**************************************************************

Disconnect external disk.

Should be accessible from a Windows pc.

**************************************************************
**************************************************************
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
My backup script was simply an example.

Your use case is quite complex, and I don't have any experience with NTFS formatted disks in TrueNAS / FreeBSD. Start putting parts of the commands in a script.

Don't forget to include error checking. For example, before a copy takes place, verify the destination is what the script expects. Meaning you don't want the 3TB copy script to run on the 2TB disk, or visa-versa. Or even have a single script that auto-detects what the destination is. Plus, I always try to create log files for my backup scripts, so I have record of when they ran, and the results.
 

dcs730

Dabbler
Joined
Jun 26, 2021
Messages
22
Hi all - Thought I would share the following solution to my backup soln.

And it solves the following...

1. Use the existing usb disks I have to backup a subset1 and subset2 of data from the DATA pool.
2. Rotate them weekly for offsite storage.
3. Use the 2x 3Tb Disks for Subset1 of DATA
4. Use the 2x 2Tb Disks for Subset2 of DATA
5. If possible, would like the ability to plug these disks directly into a Windows PC to access the data backups.

Throughout my testing - rsync does not appear to be 100% reliable with non standard characters.
TrueNAS does not 100% support USB connected disks in NTFS / FAT32. exFAT is NOT supported.
I haven't found a local app that can be installed (Like HyperBackup in a SynologyNAS) to perform backups to external disks.

So to get backup occurring from TrueNAS, I am using a simple robocopy script to run on a Windows Task Schedule.
The robocopy script runs from within a Win10 VM on TrueNAS.

Eg robocopy syntax as follows :

robocopy "x:\TrueNAS_SMB_SourceFolderShare" "e:\External_USB3DiskLocation" /E /W:1 /R:1 /X /V /FP /ETA /TEE /NP /MIR /LOG:"e:\robocopy_TrueNAS_SMB_Share_log.txt"

You'll need an external USB3 PCI-E addon card installed in your TrueNAS server. (I already had this installed).

I found an excellent article here : https://www.truenas.com/community/threads/usb-pci-passthrough-finally-possible.86243/
Credit goes to Yorick for the YouTube video.
The USB3 Host controller is only avail to the Win10 VM. CANNOT BE USED for anything on the TrueNAS host.

In my case, this USB3 XHCI controller is used purely for backups of TrueNAS via a Win10 VM.
Once configured and working, I am able to connect my external USB3 external NTFS disks.

I then run a windows script to mount the SMB shares hosted on TrueNAS, and robocopy the data from source (SMB mapped drive) to destination location (External USB3 connected disk) which appear directly inside the Win10 VM.
Copy Speeds are approx 30 MB/s.

It allows me to run external USB3 Disks and backup my TrueNAS SMB shares which can then be disconnected, stored offsite and connected to any other pc for access.

This has by far been the easiest to implement and to get working without the head-ache of rsync and mounting / dismounting ZFS external disks.

It does not some of the advantages of snapshots and zfs replication, but does give me flexibility to connect the external disks and access them quickly on another pc if required. It also allows control of what data can be copied from a source location to an external usb3 disk.
 
Last edited:

NASbox

Guru
Joined
May 8, 2012
Messages
650
@NASbox How is your procedure doing? Are you using Arwen's script or something own? When do you do scrubs and SMART tests for the removable drive(s)?
So far it has been working well. I've been using my own scripts to do the backups, and I typically run a scrub after backup and a smart every few backups. The disks I use are 14TB, so these operations take time. If I had data that was changing frequently, I'd likely keep it in separate datasets and back up to a smaller disk on a daily basis. Since my NAS is mainly media/library that only gets updated from time-to-time, I only do backups after making a meaningful number of changes.

I'm almost exclusively a Linux user, so if I do need to mount a ZFS disk, I can do it. In fact my workstation has a ZFS pool (2 disk mirror) that I use for important files. Downloads and other junk go on a standard EXT4. I back both up to TrueNAS.

I don't know if the situation has improved, but I was admonshed not to use USB disks because they are unreliable. At one point I had a 4TB USB that I used for backup a long time ago, and managed to get away with it, but I must say that I like using the Addonics removable drive cages and mounting as a local 1 drive pool. Much faster, and more reliable.
 

Jip-Hop

Contributor
Joined
Apr 13, 2021
Messages
118
8. Is there a package that can be installed in TrueNAS (Similar to HyperBackup in a SynologyNAS) that can perform the backups to external disks?
I'm also used to Synology HyperBackup, which I automated to run once the backup disk is plugged in. For TrueNAS SCALE I was looking for a similar solution. Like you I wanted to use NTFS for cross platform access, but eventually decided to go with a native ZFS solution. The result automatically snapshots and syncs (and optionally encrypts) datasets to the backup disks and sends an email notification once it's safe to unplug the disk. I made a little daemon script which listens to udev events. That way it knows when new drives are attached. If it detects it's one of your backup disks, it triggers zfs-autobackup. Seems to be working well on TrueNAS SCALE but I haven't tried it on CORE (I guess it should work). Would love to hear if anyone tries it :)
 

GJSchaller

Contributor
Joined
Feb 10, 2021
Messages
100
Seems to be working well on TrueNAS SCALE but I haven't tried it on CORE (I guess it should work). Would love to hear if anyone tries it :)
I tired on TrueNAS CORE 13.0-U3.1, and ran into an issue with the install - I've opened an issue on the GitHub repository. This looks to be exactly what I am looking for - I'll gladly help troubleshoot on CORE to get it working.
 
Top