Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Recovering Deleted Directory Structure in Ubuntu Linux

Posted on 2014-07-20
3
Medium Priority
?
1,083 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 30

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 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

When speed and performance are vital to revenue, companies must have complete confidence in their cloud environment.
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
In this Micro Tutorial viewers will learn how to restore single file or folder from Bare Metal backup image of their system. Tutorial shows how to restore files and folders from system backup. Often it is not needed to restore entire system when onl…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…

715 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