Tutorial :How Can I Recover a .nfs file?


I have been working on an algorithm in Python, and I was using Vim to edit this file. I opened it up, did a save, and it came up with an Error something like it occasionally does:


As this happens occasionally, I did what I normally do, and I hit :q! to quit without writing any changes. No harm, no foul. When I looked at my file, everything had been erased! Everything!

I talked around the office, and it seems that the nfs mount was full, and so that was why I couldn't save anything. There was a huge script generating a ton of data, which caused the mount to be full temporarily. I believe the NFS mount is from NetApp. I found 2 files in my current directory.

One was last saved two days ago, and one was today. They are in the format of:


When I try to attempt to open up this file, I see some of my code, here and there, splattered among unknown characters. Apparently, this must be a binary representation of the state of the file.

Is there any way to recover this file from this NFS mount? If there is a shortcut to recover this file in Emacs, I will switch to Emacs from vim!


So, I did find a way to recover the file. I found two ways, in fact. Since it was on a NetApp NFS mount, I was able to use the snapshots feature. When you are in a directory just do

ls .snapshot

And this will pull up any snapshots that your system administrators have set. For us, we have an hourly.0, hourly.1, and nightly.0, and nightly.1 backups. So, we can go back two days, and in the same day, we can go back one hour (the current hour, and the previous).

The other way was to rename the file to a vim swap file like this.

mv .nfs.xxx my_vim_file.cpp.swp vim my_vim_file.cpp.swp

Then attempt to open it up in Vim, and it should ask you if you want to Recover the swap file, say yes, and it should be back!


Apparently your Netapp uses NFS to mount its volumes (as opposed to iSCSI, for example). Generally, each VM is stored on a unique volume (aka datastore) on the Netapp filer. To find out the volumes and snapshots, and then restore a snapshot, here are the commands to execute at the command line:

# list all volumes, snapshots are taken of volumes  vol status  # list the snapshots available for a particular volume  snap list <vol_name>  # restore a snapshot, nightly.1 for example  snap restore <vol_name> nightly.1  

That's it. All that's left is to turn the VM back on and see if you've restored far back enough. If not, then do another "snap restore" but with an older snapshot.

Note that this procedure assumes your administrator didn't disable snapshots (Netapp has a snapshot schedule by default) and that the Netapp is licensed for snaprestore (use the "license" command to verify). This procedure can further be simplified if you have the Netapp OnCommand System Manager, which is a GUI for managing the Netapp. Reverting a snapshot in the GUI is simple:

Go to Storage > Volumes > click on a volume > click on Snapshot Copies (at the bottom)  Choose a snapshot and restore  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »