Monday, December 7, 2009

Restoring data from snapshot through snaprestore in NetApp

Ok so now you have allocated correct snap reserve space, configured snap schedules, snap autodelete, users have access to their snapshots and they recover their data without any interference of backup team. Everyone is happy so you happy but all of sudden on a Friday evening get a call from VP marketing crying on phone that he lost all his data from his network drive and windows shows recovery time of 2 hrs but he wants his 1Gb pst to be accessible now as he is on VPN with a client and needs to pull some old mails from his pst. Well that’s nothing abnormal as he was having lots of data and to recover the data windows has to read all the data from snapshot and then write back on network drive which but obvious will take time. Now what would you say, will you tell him to navigate to his pst and recover it (which shouldn’t take much time on fast connection) then try to recover all the data or ok I have recovered all your data while talking on the phone and become hero.

Well I must say I would like to use the opportunity to become hero with a minute or less of work, but before we do a few things to note.

For volume snaprestore:

  • The volume must be online and must not be a mirror.
  • When reverting the root volume, filer will be rebooted.
  • Non-root volumes do not require a reboot however when reverting a non-root volume, all ongoing access to the volume must be terminated, just as is done when a volume is brought offline.

For single-file snaprestore:

  • The volume used for restoring the file must be online and must not be a mirror.
  • If restore_as_path is specified, the path must be a full path to a filename, and must be in the same volume as the volume used for the restore.
  • Files other than normal files and LUNs are not restored. This includes directories (and their contents), and files with NT streams.
  • If there is not enough space in the volume, the single file snap restore will not start.
  • If the file already exists (in the active file system), it will be overwritten with the version in the snapshot.

To restore data there are two ways, first system admins using “snap restore” command invoked by SMO, SMVI, Filer view or system console and second by end users where they can restore by copying file from .snapshot or ~snapshot directory or by using revert function in XP or newer system. However restoring data through snap restore command is very quick (seconds) even for TBs of data. Syntax for snap restore is as below.

“snap restore -t vol -s <snapshot_name> -r <restore-as-path> <volume_name>”

If you don’t want to restore the data at different place then remove the “-r <restore-as-path>” argument and filer will replace current file with the version in snapshot and if you don’t provide a snapshot name in syntax then system will show you all available snapshots and will prompt to select snapshot from which you want to restore the data.

Here’s the simplest form of this command as example to recover a file.

testfiler> snap restore -t file /vol/testvol/RootQtree/test.pst

WARNING! This will restore a file from a snapshot into the active filesystem. If the file already exists in the active filesystem, it will be overwritten with the contents from the snapshot.

Are you sure you want to do this? yes

The following snapshots are available for volume testvol:

date            name
------------    ---------
Nov 17 13:00    hourly.0
Nov 17 11:00    hourly.1
Nov 17 09:00    hourly.2
Nov 17 00:00    weekly.0
Nov 16 21:00    hourly.3
Nov 16 19:00    hourly.4
Nov 16 17:00    hourly.5
Nov 16 15:00    hourly.6
Nov 16 00:00    nightly.0
Nov 15 00:00    nightly.1
Nov 14 00:00    nightly.2
Nov 13 00:00    nightly.3
Nov 12 00:00    nightly.4
Nov 11 00:00    nightly.5
Nov 10 00:00    weekly.1
Nov 09 00:00    nightly.6
Nov 03 00:00    weekly.2
Oct 27 00:00    weekly.3

Which snapshot in volume testvol would you like to revert the file from? nightly.5

You have selected file /vol/testvol/RootQtree/test.pst, snapshot nightly.5

Proceed with restore? yes
testfiler>

16 comments:

Anonymous said...

Of course you also need snaprestore license installed to access that function.

Unknown said...

oh yes, I forgot to mention that.

Thanks :)

raj said...

Nice & easy document on Snap restore.
:-)Cheers
Raj

MyAppleExperience said...

Can you recover a file in seconds? I think that only works on volumes and LUNs. This file recovery can take a while for a large file, no?

Unknown said...

Yes, you can, look in the post I have given an example of file restore also and that too completes in seconds irrespective of size.

testfiler> snap restore -t file /vol/testvol/RootQtree/test.pst

swarnapeta said...

so we cant restore a directory...am i ryt..

khet.richards said...

Mohit - what if you need to restore a file that exists on a lun that is within a volume? How do you go about that?

Unknown said...

Khet - For a storage system lun is a special device where filesystem is controlled by host OS and storage device doesn't have any idea what's written in physical blocks, so you have to use host OS for file recovery from inside a lun.

It can be done by 1. use snapshot copy of volume to create a lun clone, 2. map the cloned lun to similar OS as original lun 3. mount the lun in host 4. copy the file to out of the lun 4. unmount the lun from host 5. unmap and destroy clone lun from storage system.

Hope that helps

Cheers,

Unknown said...

@Swarnapeta - As mentioned in article, you can't restore a directory from snaprestore, however you can use ndmp copy or host based methods for that purpose;

"Files other than normal files and LUNs are not restored. This includes directories (and their contents), and files with NT streams."

swarnapeta said...

thnx for the response Mohit.... and wats the difference between snapdrive and snapmanager.......

swarnapeta said...

Can u keep posting on ur blogs...as we dont have anything much since 2010...ofcourse u cud be busy....but it wud be really helpful if u can take ur valuable time to explain abt Snapdrive...snapvault...snapmanager......with some screenshots(if possible)....or else...share some resourses if possible....
Thnx and regards,
Swarnapeta.

Unknown said...

@Swarnapeta - Yes, I was caught up with different things, like change of country, job and then my busy schedule, however now it feels like I am back on track and sure will start the blogging again.

Thanks to all you guys for your continuous support and kind words.

Cheers.

Machavarapu said...

hai friend,

i can,t able to do snaprestore.

my file name is is like this "t e s t.txt"

I follwed below syntax
netapp-05>snap restore -t file -s snap3(name)/vol/vol1/nstor/t e s t.txt

can you give me solution plz

Vamsikrishna Machavarapu

Dan said...

Hi,
we just got our first FAS running. Now there is a problem while restoring files.
Can 'snap restore' command on cli restore files in a user home directory?
The home-dir is ACL-restricted for the user himself only. I have no access to it, not even listing the files.
While restoring other data we do that by restoring/copying the files from the .snapshot folder which works fine. But this is not possible with home dirs.

Can you please give some help?

Unknown said...

Have you checked if file is present in snapshot and if yes the name you are supplying is correct?

If there is a space in file name I would request you to use quotes in path as well to keep it simple you can remove the snapshot name flag which in turn will prompt you to select the snapshot you want to restore if from.

snap restore -t file "/vol/testvol/RootQtree/"

If that doesn't work please paste full command you are parsing so I can look into.

Unknown said...

Hi Dan,

To restore a file you need full path name in the form of /vol////, so if you don't have exact file details I would request you to have user do a restore using previous versions tab in windows or navigating to ~snapshot or .snapshot directory as the case may be.

In order to restore using snap restore command to my knowledge and understanding it should work and should not have any problem with permission however I have never tried this scenario therefore can't comment on it confidently but have you tried it? If yes what was error you were getting?

Cheers.