Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

How to recover deleted file?

seanm

Senior Member
Joined
Jun 11, 2018
Messages
475
Let's say I have an SMB share and a coworker deleted something he shouldn't have. Assuming there are snapshots that contain the file (ie the file wasn't deleted 2 seconds after being created), how do I restore the file?

I did search the docs, but I don't see this topic covered at all. I'm happy to be pointed to the right docs. Thanks!
 

Redcoat

Dedicated Sage
Joined
Feb 18, 2014
Messages
1,668
See notes on "rollback" in Section 9.2 of the manual and find this text:

"To restore the data within a snapshot, the recommended steps are:
  1. Clone the desired snapshot.
  2. Share the clone with the share type or service running on the FreeNAS® system.
  3. After users have recovered the needed data, delete the clone in the Active Pools tab.
This approach does not destroy any on-disk data and has no impact on replication."
 

Johnny Fartpants

Neophyte Sage
Joined
Jul 3, 2015
Messages
571
Or expose the snapshot via 'previous versions' on the share config
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
6,745
ZFS rollbacks are destructive. The easiest way to restore is to copy out of the hidden .zfs/snasphot/ directory at the root of the ZFS dataset. If this is an SMB share you can access them through "previous versions" on a windows client or directly mounting the zfs snapshot directory on a macos client.

Example of mount string for MacOS on FN 11.3 smb://192.168.122.123/SHARE/.zfs/snapshot. You can do the same in 11.2, but you need to remove the "veto files=.zfs" parameter from the share. You can do this by adding the auxiliary parameter veto files = /.windows/.mac/
 
Last edited:

Fredda

Neophyte Sage
Joined
Jul 9, 2019
Messages
605
If you have snapshots in place, select it in the configuration of your SMB share.

snapshot.png


With this setting you can restore that file via the windows properties dialog in tab "Previous Versions".
If the file was deleted just create an empty one with the same name.

If a whole bunch of files/directories was deleted use anodos' solution.
 
Top