Third-party backup (crashplan) of ZFS snapshots sent to FreeNAS from another computer

Tom_

Explorer
Joined
Jan 4, 2015
Messages
62
TLDR: Is there a way to back up ZFS snapshots, sent to FreeNAS from another computer (or the contents of the snapshots) to Crashplan?

The details:

I am running FreeNAS-9.10.2-U6. It's been rock solid so I haven't felt the need to upgrade.

I'm backing up files stored on the NAS to Crashplan via Ubuntu 16.04.6, running under iohyve on the FreeNAS box. The datasets I want backed up are shared from FreeNAS to the Ubuntu guest using NFS. For the most part this has also been pretty stable. I have 3 TB stored with crashplan.

One of my desktop computers is running Ubuntu 19.10 with a ZFS mirror for /home. This computer is sending snapshots from /home to a dataset on the FreeNAS box for backup. I'd like to get that data backed up externally from the FreeNAS box, too (i.e. send them to Crashplan).

Is there a sensible way to do this?

For example, can I mount the latest snapshot in FreeNAS and export the mountpoint by NFS? I guess I could un-mount and remount the latest snapshot once a day with a Cron Job on FreeNAS to make sure files from a recent snapshot are being backed up. I'm not really sure how to achieve this though.

Other things I have considered:

- Ditch crashplan, upgrade to current FreeNAS, and use B2 instead. But it doesn't look like Cloud backup in current FreeNAS sends snapshots to B2, anyway.
- Find a backup provider who accepts ZFS snapshots, e.g. Rsync. Probably too expensive for a home setup.
- Export /home from the Ubuntu 19.10 desktop directly to the Crashplan guest. The desktop is not on all the time so the directory would be dropping in and out of the Crashplan dataset, which I don't think the Crashplan software likes.
- Install ZoL on the Crashplan guest and mount the snapshot there. I'm not terribly hopeful about ZoL on a version of Ubuntu that is almost 4 years old.
- Use a separate solution for backing up the Ubuntu 19.10 desktop.

I'd appreciate any suggestions.

Thanks for reading!
 

toadman

Guru
Joined
Jun 4, 2013
Messages
619
I guess whether or not it's "sensible" is subjective.

The snapshots themselves are stored in the [filesystem]/.zfs/snapshot directory. I believe (though I haven't tried) you can send the snapshot to an external filesystem, crashplan in your case. The issue would be that it sends the entire filesystem because the receiving side is not ZFS. i.e. if you send two nearly identical snapshots of a 1TB sized filesystem you'd end up with 2TB on the receiving side. (And you'd have to account for a 1TB network transfer time as well in this example.)

So I would suggest that the answer depends on the size of data you want to send to crashplan (snapshot is X GB), how many copies, and the frequency of transfer.

I don't know enough about how Crashplan works now to suggest something different. But can you not just run Crashplan on the desktop and send files to the code42 cloud that way? or reconfigure and send files to both your ubuntu16.04 vm and the cloud as a multi destination config?
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
Zfs send the snapshots to a file then backup that file.
 

Tom_

Explorer
Joined
Jan 4, 2015
Messages
62
Thanks for the replies.

The issue would be that it sends the entire filesystem because the receiving side is not ZFS. i.e. if you send two nearly identical snapshots of a 1TB sized filesystem you'd end up with 2TB on the receiving side. (And you'd have to account for a 1TB network transfer time as well in this example.)

Zfs send the snapshots to a file then backup that file.

Yep, as you said, I think this would mean uploading the whole snapshot every time. Uploading to crashplan is really slow - I'm not sure if it would finish before the next day's snaphot...!

But can you not just run Crashplan on the desktop and send files to the code42 cloud that way? or reconfigure and send files to both your ubuntu16.04 vm and the cloud as a multi destination config?

This is also an option but crashplan charges per device, so it would double the monthly cost.

I can't think of anything better than grepping zfs list for the latest snapshot, and mounting that with mount -t zfs once per day, e.g.

Code:
#!/usr/bin/env bash

set -eux

check_mount () {
    python -c 'import os,sys; print(os.path.ismount(sys.argv[1]))' $1
}

DATASET="tank/zhomebackup"
MOUNTPOINT="/mnt/tank/zhomebackup"

# create the mountpoint if necessary
if [ ! -d "${MOUNTPOINT}" ]; then
    mkdir -p "${MOUNTPOINT}"
fi

# find latest snapshot in DATASET
LATEST="$(zfs list -t snapshot -o name -s creation \
    | grep "${DATASET}" \
    | tail -n 1)"

# check if anything is mounted at MOUNTPOINT
IS_MOUNTED="$( check_mount "${MOUNTPOINT}" )"
if [ "${IS_MOUNTED}" == "True" ]; then
    # unmount then check again
    umount "${MOUNTPOINT}"
    IS_MOUNTED="$( check_mount "${MOUNTPOINT}" )"
fi

# mount LATEST to MOUNTPOINT
if [ "${IS_MOUNTED}" == "False" ]; then
    mount -t zfs "${LATEST}" "${MOUNTPOINT}"
else
    exit 1
fi

exit 0


Thanks again, I'd be interested to hear if anyone has any thoughts on that and/or other ideas.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Yep, as you said, I think this would mean uploading the whole snapshot every time.
It would mean uploading the snapshot file. It would take some scripting if you wanted to automate this, but you could do an incremental zfs send of the current snapshot with reference to the last one, and the resulting snapshot file would only contain the changes.
 

Tom_

Explorer
Joined
Jan 4, 2015
Messages
62
Actually, this might be easier than I thought. I just tried
Code:
DATASET="tank/zhomebackup"
MOUNTPOINT="/mnt/tank/zhomebackup"
zfs set mountpoint="${MOUNTPOINT}" "${DATASET}"
zfs set sharenfs=ro "${DATASET}"
chown guest:users "${MOUNTPOINT}"

... and now I can see the files from the crashplan VM. (guest:users is how my NFS shares are mapped, all read only.)

When I went onto the ubuntu desktop, added a new file, and sent a new snapshot to FreeNAS, I could see the new file straight away on the crashplan VM.

I don't know if it will survive rebooting FreeNAS but it's easy to add a script if not.
 
Top