Creating datasets without UI?

Dunuin

Contributor
Joined
Mar 7, 2013
Messages
110
Hi,

I wrote a backup script to mirror my pool a raidz1 on USB3-Disks.
But if I use zfs create "${pool}/${dataset}" to manually create a new dataset I get an error that the new dataset can't be mounted.
Do I need to set the mountpoints manually? Where should I mount my backup pool? What other parameters do I need to configure so the manually created dataset is compatible with FreeNAS?
I've created the backup pool with the FreeNAS ui, exported it and use this commands in a bash script to mount and mirror the pool.
Manually imported pools don't show up in the ui but that is fine as long as I'm able to import the pool via the ui after it is manually dismounted. But if I mount it using the ui I want everything to work normal.

These are the simplified commands I use:
Code:
//mount pool
geli attach -j ${GELI_PWDFILE} -k ${GELI_KEYFILE} "${backuppooldevice}"
zpool import $backuppool

//check if dataset exists, if not create it
zfs list -H -d0 -o name "${backuppool}/${masterpool}" # > /dev/null 2>&1
if [ $? -ne 0 ]; then
    zfs create "${backuppool}/${masterpool}"
fi

//replicate pool
zfs snapshot -r "${masterpool}/${dataset}@${newSnapName}"
zfs send -R -v "${masterpool}/${dataset}@${newSnapName}" | zfs recv -F "${backuppool}/${masterpool}/${dataset}"

//unmount pool
zpool export $backuppool
geli detach "$backuppooldevice"


I hope someone with more ZFS knowlage can help me.
 
Top