Hi,
Consider a dataset appdata with snapshots in pool main:
main/appdata@s1
main/appdata@s2
main/appdata@s3 # newest snapshot
Now, I’d like to restore old snapshot main/appdata@s2. This should result in appdata content to be same as main/appdata@s2. The kicker is: I still need to keep main/appdata@s3 for testing purposes.
Two remaining alternatives seem to exist:
- Copy over needed files from
main/appdata/.zfs/snapshot/s2back to dataset. - Clone
main/appdata@s2; promote and rename this clone to replace original dataset.
If I am not mistaken, ZFS rollback does not work, as it deletes all newer, intermediate snapshots (and can cause errors with ZFS incremental replication).
Alternative 1
This sounds like simplest solution. I could do
rm -rf main/appdata/big_folder
cp -a main/appdata/.zfs/snapshot/s2/big_folder main/appdata
, but that probably isn’t optimal (size is 200GB). I guess
zfs send main/appdata@s2 | zfs recv -F main/appdata
would be much more time-efficient, leveraging ZFS block transfers?
Alternative 2
Snapshot cloning and promoting can be done as shown in TrueNAS docs. Or via command line:
zfs clone main/appdata@s2 main/appdata-clone
zfs promote main/appdata-clone
This clone needs to be renamed to original dataset name (not possible with web app):
zfs rename main/appdata main/appdata-old
zfs rename main/appdata-clone main/appdata
# optionally later on ...
# zfs destroy -r main/appdata-old
Is this rename operation OK without causing any inconsistencies in TrueNAS / do I need to stop any services before?
Being relatively new to TrueNAS/ZFS, I’d appreciate confirmation, if my understanding is correct so far and how to do proceed. Thanks!
TrueNAS SCALE 24.10