If something bad happens with your FreeNAS jail you might want to go back in time and just restore the jail from a previously saved snapshot of the jail dataset. Of course, this assumes that you previously have taken snapshots to restore from for the jail, either automatically or manually. If so, this howto describes how you can restore the state of your jail to any of those snapshots.

HowTo restore FreeNAS jail from dataset snapshot/backup

  1. Go to the snapshots for the jail.
  2. Find the snapshot you want to restore to.
  3. Clone that snapshot.
  4. Stop the jail that you want to restore: Jails -> View Jails -> Select your jail -> Click the red stop button.
  5. Go into the FreeNAS shell from the FreeNAS GUI.
  6. Rename the dataset of your bad jail but remember the original name (write it down) since you need it later.
    • zfs rename <your_jails_pool_name>/jails/<your_bad_jail_name> <your_jails_pool_name>/jails/BadJail
  7. If you get: “cannot unmount ‘<your_jails_pool_name>/jails/<your_bad_jail_name>’: Device busy” your dataset is in use. This is the case if you haven’t stopped the jail (see above) but sometimes it is in use anyway. You should then try to figure out what is using it and fix the issue. If you cannot figure it out you need to force unmount your jail. It should be fine but this could be a risk since it is in use by someone/something. Proceed at your own risk.
    • zfs unmount -f <your_jails_pool_name>/jails/<your_bad_jail_name>
    • Now try to rename the dataset of your bad jail again: zfs rename <your_jails_pool_name>/jails/<your_bad_jail_name> <your_jails_pool_name>/jails/BadJail
  8. Now rename the good snapshot of your jail to the original name of your jail dataset (the one that we called <your_bad_jail_name> above)
    • zfs rename <your_jails_pool_name>/jails/<name_of_good_snapshot_of_your_jail> <your_jails_pool_name>/jails/<original_jail_dataset_name>
  9. Start the jail again: Jails -> View Jails -> Select your jail -> Click the green start button
  10. Your jail should now be in a nice state according to you good snapshot.