[HOWTO] Recover / Undelete deleted files from NAS

Backup, Restore, Q-Back 25s/35s, Netbak Replicator

[HOWTO] Recover / Undelete deleted files from NAS

Postby avvidme » Fri Apr 23, 2010 10:55 pm

I had an earth shattering 100GB file deletion which included dozens of thousands of important files. This happened through an Rsync error (human error) in which Rsync deleted files permanantly on my TS-639 running RAID 5 on EXT4 formatted system.
Unfortunately, in the manner these files were deleted, the Ry-cycle bin did not have these files. On the QNAP forums and with what I mostly read - I was out of luck.

After a lot of research, I was able to recover over 66,000 files!!!
I thought I'd share my success and how to do this step by step.

My situation: 2 x TS-639's both with 1.5tb's running Raid 5 and EXT4. Firmware 3.2.5 Build 0410T
I do know, that running almost any style of hard drives (mirrored, raid etc.) will work, and MANY versions of the firmware back to v2. (linux 2.4.x - 2.6.x kernels)

Although this was done on a QNAP NAS, this will work on MANY brands of linux 2.4/2.6 based Intel NAS's. I don't believe it'll work on non-Intel based.

----------------------------
What you need:
1) An external USB or eSata drive large enough to hold your deleted data (more on this later) - Or if you have another partition that you can safety write to, this might suffice
2) Download and decompress on your PC/Mac etc. "Linux, kernel 2.6.x i386/x86_64 " from http://www.cgsecurity.org/wiki/TestDisk_Download

A couple of important notes:
1) Stop using your NAS NOW! The more files that get written to your NAS, the more files you will NOT be able to undelete. This includes even the log files that the NAS generates. I'd recommend turning off all services, applications and protocols except for the basic minimum (SMB, AFP etc.)
2) You MUST copy your undeleted files to the external USB/eSata drive. This program does not "undelete" like Microsoft where it restores the file where it sits, it literally re-writes the new "recovered" file - and thereby will overwrite the files you are trying to undelete.
3) Testdisk vs. Photorec : My partition was in tact and my goal was to recover deleted files only. In this case I'd strongly recommend using PhotoRec vs. Testdisk. Ignore the filename, as PhotoRec recovers MUCH MORE than just photos. If you are recovering from a deleted or corrupt partition - use Testdisk. Much of these instructions would also apply to Testdisk, although the specifics would change. The scope of this HOWTO is to undelete files using PhotoRec

Disclaimer: Obviously this isn't supported by QNAP - although if you ENSURE you recover your files to another partition or external drive, this process is also non-destructive to your existing partition as it only reads from your existing partition/hard drive.

-----------------------------
STEP 1 - Plug in your external drive, format it (EXT3 or 4) and make a directory to copy the uncompress TESTDISK/PHOTOREC files into.
STEP 2 - SSH/Telnet into your NAS, and find your way to the directory in which PhotoRec resides.
Image
*You can see from diagram above that I changed to PhotoRec's directory "CD /share/USBDisk1/DISK/linux" on my external USB drive. The DISK directory is what I created on the USB drive, and copied the uncompress testdisk/photorec files & dirs into this

STEP 3 - Execute PhotoRec_Static package by using "/share/USBDisk1/DISK/linux/photorec_static" as below. Obviously replacing path with your own.
Image

STEP 4 - PhotoRec will ask you to create a log file, say yes (this will be stored in the same directory you're in) - important that you've changed directory to the USB drive for this purpose
STEP 5 - Your hard drives will be shown as below. NOTE: You will see your individual drives - select accordingly if you're recovering from a single drive. Or as the picture shows below, select the /DEV/MD0 drive which would usually be your entire RAID volume if it's still in tact. Select your drive and use your right arrow key to highlight PROCEED and hit ENTER

Image

STEP 6 - Select your partition type and hit ENTER. Photorec recommends staying with what it has determined on it's own and defaulted to. In my case it was "None". Although it also might default to "Intel"
Image

STEP 7 - Pick your partition. In my case I had 1 RAID 5 formatted to EXT4, therefore it looked as below; (NOTE: Don't hit ENTER yet!)
Image

STEP 8 - Using your right arrow key, move the bottom menu to "File Opt". You can also play with "Options" depending on your situation, although the defaults were fine for my use. I would STRONGLY suggest you spend a few minutes on this menu (as below) and De-Select the files that you are not interested in recovering. This will save a LOT of time in the recovery process. Use up and down arrow keys, spacebar to toggle. Press ENTER when done.
Image

Step 9 - Select the EXT2/EXT3/EXT4 file system on the next menu as below
Image

Step 10 - Important option here on the next screen. You'll have a choice of "Free" or "Whole" to scan. If you're recovering from a partition corruption etc. you'll probably want to do Whole. In my case just with file deletion, you will want to choose "Free" to scan for free space only. The Time difference (in my situation) was 320Hrs (Whole) vs. 8Hrs (Free).
Image

Step 11 - IMPORTANT STEP! This prompt (below) is asking you where you want the recovered files to be written. Once again you do NOT want these written to your NAS unless it's on a totally different partition. I'd suggest either different partition or external drive. Use your right and left arrow keys to navigate to the drive where you want the files restored, then press "Y" to start the recovery process. NOTE: When you press "Y", the recovery process will start. In my case, it ran for almost 9 hours - obviously mileage will vary greatly depending on your options and situation.
Image

This process will create automated and auto numbered directories and file names during the restoration process.
Note: Unfortunately your filenames and directory names will NOT be restored. I would install and use an indexing and search engine on your PC and use that to index files and contents of files- this helped me recover the files I was looking for.

I had great success with this process and tool, with restoring over 66,000 files.

I hope this helps someone else in their moment of panic!
Feel free to email/respond if you feel my experience can help you in any way.

Cheers!
_______________________________________________________________________
Checkout http://www.digitalgatehouse.com for more of my ramblings!
User avatar
avvidme
Know my way around
 
Posts: 174
Joined: Fri Jan 16, 2009 10:36 am
NAS Model: TS-459 Pro

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby jumper6 » Wed Apr 28, 2010 9:13 pm

I just accidently deleted several thousand files from my NAS and am in the same position. I connected an eSATA disk to my TS-639 but can't seem to find a way to write to it. When I try to copy the photorec files to the eSATA disk the NAS will not let me write to the disk. I am logged in as admin and have full rights. Can anyone please assist?
TIA
QNAP-TS859, RAID 6, 8x 2tb Seagate Drives on GIG Network
User avatar
jumper6
Starting out
 
Posts: 35
Joined: Thu Jan 29, 2009 9:34 am
Location: Seoul, Korea
NAS Model: TS-659 Pro

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby avvidme » Fri Apr 30, 2010 9:03 am

Have you formatted it under the NAS to ext3 or 4? When done, go to Access Right, and Shared Folders - ensure it's shared out with the proper access (admin etc.)
This is all I needed to do.

Cheers
J
_______________________________________________________________________
Checkout http://www.digitalgatehouse.com for more of my ramblings!
User avatar
avvidme
Know my way around
 
Posts: 174
Joined: Fri Jan 16, 2009 10:36 am
NAS Model: TS-459 Pro

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby pixelgrit » Fri Apr 30, 2010 6:04 pm

@avvidme

Thanks so much for this post, it just saved my **. I cannot for the life of me work out why QNAP share folders work the way that they do. If i remove a share on a directory in any other OS, linux, windows, osx ; it removes shared access to the folder, it does NOT delete the entire contents of the folder, like the QNAP NAS does. This is crazy! I just lost about 8 years and 113 GB of photos by removing a network share via the QNAP web interface. Why on earth does it work this way? It should at least warn you when you remove a folder share, "Are you sure you want to remove this share; by removing this share QNAP will delete all of the contents of this share!". So a big thanks to avvidme as I have restored a good 8 months worth of photos and have found backup's for the rest. I will definitely be returning my QNAP and purchasing another brand which handles share folders correctly - don't get me started on the default shares you are required to have under the QNAP OS... crazy **. For such a solid hardware setup and some good aspects of the interface design, it lacks fundamental concepts!

b
pixelgrit
New here
 
Posts: 4
Joined: Fri Apr 30, 2010 5:55 pm
NAS Model: TS-239 Pro II

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby avvidme » Fri Apr 30, 2010 7:52 pm

I'm very happy my horrid experience has helped someone. Too bad about your choice on leaving QNAP though, out of all the NAS's it's still my favorite.
My mistake was pure human error (as it sounds yours) - although I agree, they could put a few extra prompts in some of the UI's interfaces in some of the crucial areas.

Cheers
_______________________________________________________________________
Checkout http://www.digitalgatehouse.com for more of my ramblings!
User avatar
avvidme
Know my way around
 
Posts: 174
Joined: Fri Jan 16, 2009 10:36 am
NAS Model: TS-459 Pro

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby avvidme » Fri Apr 30, 2010 7:54 pm

Btw pixelgrit: If you recreated the share with the same path and name, your data would have probably been there and in tact.
_______________________________________________________________________
Checkout http://www.digitalgatehouse.com for more of my ramblings!
User avatar
avvidme
Know my way around
 
Posts: 174
Joined: Fri Jan 16, 2009 10:36 am
NAS Model: TS-459 Pro

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby pixelgrit » Sat May 01, 2010 7:45 pm

ah! i wish i had read your reply, before i re-created the "deleted" directory with my restored data - i would have have found out if indeed it was still there. since i have now recreated a directory with the same name in the same spot, i doubt whether it would still be in tact. anyway thanks again for you help; it has totally saved my bacon. i am still on the fence about returning this product (aside from the fact i need to offload 2TB of data to somewhere), since you mention it's the best NAS you've delt with.
pixelgrit
New here
 
Posts: 4
Joined: Fri Apr 30, 2010 5:55 pm
NAS Model: TS-239 Pro II

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby jumper6 » Sat May 01, 2010 9:08 pm

Finally had a chance to sit down and get this going. It has been running now for 13 hours and has recovered 169K files so far. States that it will finish in 7 hours/. It has 7.6tb to get through so I understand why it is taking so long. I did notive that the directory structure is completely gone and all of the files it has recoverd so far have been renamed. It's going to be lots of fun trying to put all of this back together, but I guess it's better than losing everything. Thanks again for your post, it has saved me years of memories and files that I thought were lost forever!!
QNAP-TS859, RAID 6, 8x 2tb Seagate Drives on GIG Network
User avatar
jumper6
Starting out
 
Posts: 35
Joined: Thu Jan 29, 2009 9:34 am
Location: Seoul, Korea
NAS Model: TS-659 Pro

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby Sparre » Sun May 02, 2010 4:27 pm

Hi....

I have tried the suggested procedure on my QNAP 209-II Pro after accidentially deleting a share (pointing towards my music-folder on the NAS).

When I try to execute the photorec_static (/share/USBDisk1/linux/photorec_static) it responds 'Cannot execute binary file'.

There is full access on all files (777) and I have set the permissions for the USBDisk1 (admin rights).

Tried the kernel 2.6.x i386/x86_64 and kernel 2.4.x i386/x86_64 and the i386 RPM .... just to be sure ;-)

Optware ipkg is installed and functional,,,,

Any suggestions ?

Thanks in advance....


/Klaus
Denmark
Sparre
First post
 
Posts: 1
Joined: Fri Apr 10, 2009 10:17 pm
NAS Model: TS-109/209 Pro

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby avvidme » Sun May 02, 2010 8:51 pm

Hi Sparre,

Sorry but as I mentioned in the posting - I believe this would only work on Intel based NAS's since the photrec_static is compiled for Intel based systems only, and I assumed would not work on the Marvell CPU's.

Cheers.
_______________________________________________________________________
Checkout http://www.digitalgatehouse.com for more of my ramblings!
User avatar
avvidme
Know my way around
 
Posts: 174
Joined: Fri Jan 16, 2009 10:36 am
NAS Model: TS-459 Pro

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby Yeroon » Thu May 06, 2010 5:15 pm

Great HOWTO, i'm very, very pleased with this.
I'm not in need of this yet, but you never know.
On my Windows PC i can recover deleted files, but i didn't know how to do this is on a linux machine.

Very useful info! Thank you. :D
Rats live on no evil star
TS-509 - FW 3.4.0 Build 0212T- 2x2Gb Kingston KVR667D2S5K2
User avatar
Yeroon
Getting the hang of things
 
Posts: 80
Joined: Wed Sep 09, 2009 6:40 pm
NAS Model: TS-439U-SP/-RP

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby avvidme » Thu May 06, 2010 8:26 pm

Thanks! Hope you never need it :)
_______________________________________________________________________
Checkout http://www.digitalgatehouse.com for more of my ramblings!
User avatar
avvidme
Know my way around
 
Posts: 174
Joined: Fri Jan 16, 2009 10:36 am
NAS Model: TS-459 Pro

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby jumper6 » Thu May 06, 2010 9:30 pm

I just wanted to post my final resolution using the method in this thread. I was able to recvover everything that I lost...tens of thousands of files. Absolutely fantastic. Now I am combing through all the files to try and catalog them properly. I did run into one snag that may help others. When I ran the program and got to the options screen, I was able to tab over, but I was not able to select any options by pressing the enter key. In the end I used keyboard commands using the first letter of the command to get through the different options Other than that small hiccup, this method works perfecly. Thanks again!!!
QNAP-TS859, RAID 6, 8x 2tb Seagate Drives on GIG Network
User avatar
jumper6
Starting out
 
Posts: 35
Joined: Thu Jan 29, 2009 9:34 am
Location: Seoul, Korea
NAS Model: TS-659 Pro

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby avvidme » Thu May 06, 2010 10:09 pm

Great to hear! And thanks for adding the tip.
Cheers
_______________________________________________________________________
Checkout http://www.digitalgatehouse.com for more of my ramblings!
User avatar
avvidme
Know my way around
 
Posts: 174
Joined: Fri Jan 16, 2009 10:36 am
NAS Model: TS-459 Pro

Re: [HOWTO] Recover / Undelete deleted files from NAS

Postby davidgreem » Tue May 11, 2010 11:47 pm

In order to recover the deleted files on NAS, you can go for the software option that recover all the deleted files and another option is Undelete File software is an undelete files utility to undelete lost files from Windows Recycle Bin which has been lost due to the format or corruption of a hard drive, virus or Trojan infection or software failure. Recover Data for undelete files recovery software can easily undelete files & lost data which has been accidentally deleted. Undelete files software can recover deleted files from formatted NTFS & FAT partitions of Windows hard drive.
Mistakes are the portals of discovery
davidgreem
New here
 
Posts: 5
Joined: Fri Apr 09, 2010 6:18 pm
NAS Model: TS-439U-SP/-RP

Next

Return to Backup & Restore

Who is online

Users browsing this forum: No registered users and 2 guests