Solved

Recovering Deleted Directory Structure in Ubuntu Linux

Posted on 2014-07-20
3
849 Views
Last Modified: 2014-08-09
Hi folks!

Got an Ubuntu 12.04.3 LTS server that is acting as a file server for our network using Samba. Had a bunch of files and folders that got accidentally deleted.

I was able to use the Foremost tool to recover a bunch of the files, but it seems to recover them by file type and sort the recovered files that way (e.g. I now have one folder for all the recovered JPG files, one for all the XML files, etc.) with no indication of what directories they came from. That's a particular big deal on this machine, since there are tons of different small directories that originally housed these files.

So... do I have any hope here? Any way for me to get these files back to their original directories rather than just having a big pile of files to work from?

Thanks,
Ithizar
0
Comment
Question by:Ithizar
3 Comments
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 40208067
Perhaps TestDisk would do a better job. See here for step-by-step instructions.
0
 
LVL 28

Expert Comment

by:serialband
ID: 40209817
If you aren't backing up your file server, you should start doing that now.  That would save you much aggravation.  You should also be testing your backups periodically.  Many companies run backup solutions but never test them, so they don't ever know if the backups actually worked.
0
 
LVL 20

Accepted Solution

by:
tfewster earned 500 total points
ID: 40210300
I typed a long answer, but my browser crashed and it's late, so here's the short version for now...

A directory is just a type of file (containing a list of inodes it contains and the associated filenames) so theoretically Foremost could recover directory file types as well.
http://www.howtoforge.com/recover-deleted-files-with-foremost - "You can tweak /etc/foremost.conf to add support for more file types"

That would give you a "flat" set of directory files, with the names being the original inode numbers

Before starting the reorganisation, make a copy of the complete ~/output directory as a working set.

Starting at the level that wasn't deleted, e.g. /data/shared, examine that directory with `strings` or a hex editor to find the inode numbers and filenames it should contain; Move and rename the recovered directories into that directory, then examine each subdirectory for inode numbers/names and repeat until finished.

Do the same for the recovered jpgs etc.

Hard links can also be recreated, with some further detective work.

Hopefully Foremost has recovered the owner:group and permissions, which should help.

As well as backups, you probably want to prevent file deletions in future; Samba or the directory "sticky bit" may help with that.

Hope that helps...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lets start to have a small explanation what is VAAI(vStorage API for Array Integration ) and what are the benefits using it. VAAI is an API framework in VMware that enable some Storage tasks. It first presented in ESXi 4.1, but only after 5.x sup…
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now