Solved

Recovering Deleted Directory Structure in Ubuntu Linux

Posted on 2014-07-20
3
813 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 27

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

From Coral's  "So You Want To Play With Computers" Series Preface: What follows is a tweaked reprint from 2005/06. This is a True Story. The names have been changed to protect the guilty. While this deals with a fairly simple, text file recovery…
First I will try to share a design of a Veeam Backup Infrastructure without Direct NFS Access backup. Note: Direct NFS Access backup transport mechanism is only available in Veeam v9 In above I try to design the Veeam Backup flow between i…
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…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

744 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

9 Experts available now in Live!

Get 1:1 Help Now