When you have a Freenas you need sometime to make a backup of the entire volume.
I have a external HDD drive ( connected with a USB interface). I want to have a exact replica of the entire Freenas dataset so that I can store it on a remote location. The GUI menu from Freenas allow you to do this but as a scheduled replication task . This is nice if you have another NAS connected on the network. In my case I have just a external HDD (1TB) and I want to make a backup from time to time.
First connect external HDD on Freenas USB ports. Plug the cable and then from GUI go to Storage–> Volume–> import Volume.
In the new pop-up select the ZFS volume from your HDD. If you do not have a volume yet then you can create it from GUI .
Now you have to open a terminal because next commands are not possible from GUI.
So you can open the Shell from GUI Freenas ( left side menu) or you can use a SSH to access directly the Freenas terminal.
In the Freenas terminal you need first to check if you see correctly the NAS volumes and also the new inserted external HDD volume.
zfs list –> to see all volumes available
then type :
zfs list -t snapshot –> to see what snapshots you have on your system.
First time when you make this transfer you will need to copy a lot of data since external HDD is empty . Do not worry because next time when you make backup only the difference data will be copied. So it will be much faster.
So first time do:
zfs snapshot -r data1/bsdshare@backup # create a snapshot
zfs send -R data1/bsdshare@backup | zfs receive -vF bkp_1T # transfer it over
zfs snapshot = create a snapshot of the data
-r = snapshot is recursive
data1/bsdshare = my volume is “data1″ and dataset is”bsdshare”
backup = arbitrary name for my snapshot. (you can see it also in GUI on Storage–>Snapshot)
zfs send = copy the dataset
zfs receive = paste the dataset
bkp_1T = is the name I chose for my external HDD volume ( choose any name you like)
The zfs send/receive command take very long time !! hours !! since will copy now the entire data. May be longer/shorter depending on the total data, HDD speed, USB interface..etc.
At the end , after the send/receive finished you can detach the external volume from GUI . Go to Storage–> Volumes, click on the “bkp_1T” and select “detach”. Now you can unplug the external HDD and you are ready.
Next time when you want to update the data from external HDD you need to do the following. The idea is to make a incremental update so that you do not spend hours copying entire data again . For this we will do:
First plug the external HDD on USB port. ( Notice that Freenas do not require any reboot !!, all is live)
From GUI import volume . Go to Storage –> Volumes –> import volume. Select the volume from your HDD ( mine is called “bkp_1T”)
Now open again a terminal in Freenas ( from GUI menu or with SSH) and type:
zfs rename -r data1/bsdshare@backup data1/bsdshare@backup_old
# rename the “old” snapshot made last time from “backup” into “backup_old”.
zfs snapshot data1/bsdshare@backup # take a new snapshot
zfs send -Ri data1/bsdshare@backup_old data1/bsdshare@backup | zfs receive -v bkp_1T # incremental replication
Notice that now we use -i and we add both snapshot ( old and new) for send command. Now only the delta between old-new will be copied to HDD so it should take seconds or minutes, not hours/days.
At the end check one more time ( from GUI or terminal) that sizes, disks and snapshots are ok . If OK then you can optionally cleanup the storage by removing the old snapshots from Freenas and also from external HDD.
zfs destroy -r data1/bsdshare@backup_old # get rid of the previous snapshot from Freenas
zfs destroy -r bkp_1T@backup_old # get rid of the previous snapshot from external HDD
At the end from GUI you can detach the external HDD ( Storage–> Volumes , click on volume and select detach)
That’s it !