Send Receive Encrypted ZFS Dataset and All Snapshots
Moving an Encrypted Dataset is not a complicated task but can require a little work if you have snapshots which you want to move as well. A handy tip to accomplish this is to create a recursive snapshot before moving and then send this snapshot to get all moved easily.
Tip
Create a recursive snapshot and send this snapshot to send all snapshots:
zfs snap -r tank/archive@move-dataset
Now send this recursive snapshot:
zfs send -Rw tank/archive@move-dataset | zfs recv -Fuv tank2/archive
Steps to Move Encrypted Dataset with All Snapshots
- create a recursive snapshot (so we can transfer all snapshots):
zfs snap -r tank/archive@move-dataset
- send snapshot:
zfs send -Rw tank/archive@move-dataset | zfs recv -Fuv tank2/archive
- verify/check received snapshots:
zfs list -t snapshot tank2/archive
- verify/check keys (if keylocation is blank set it accordningly):
zfs get encryption,keylocation,keyformat tank2
- if keylocation is blank set accordingly:
zfs set keylocation=file:///your/key/location tank2/archive
- if keylocation is blank set accordingly:
- after send and checking mountpoint the mount (
zfs mount tank/archive
) will likely fail with 'encryption key not loaded', to fix this load the key:zfs load-key tank2/archive
- mount new location:
zfs mount tank2/archive
- check snapshots and data
I run a non-systemd system so I also need to add the loadkey to my ZFS init script (/etc/init.d/zfs
) to ensure the key is loaded at system start.
Note
Its a good idea to reboot and make sure the dataset is automounted and there are no issues.