Solved

Recovering Deleted Directory Structure in Ubuntu Linux

Posted on 2014-07-20
3
939 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 29

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 21

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

If you ever consider purchasing any Daossoft Software Products, DON'T expect any meaningful support - This article should convince you why!
Employees depend heavily on their PCs, and new threats like ransomware make it even more critical to protect their important data.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
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…

710 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