Accidentally deleting directory/files


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Accidentally deleting directory/files
# 1  
Old 08-27-2003
Data Accidentally deleting directory/files

Hi,
I accidentally deleted a big directory with all its sub-directories and bunch of source code files which I have been developing for about 2 years... What will I do now, how can I retrieve my files, directory hierarchy back ???

If anyone, please HELP ! ! ! ...
# 2  
Old 08-27-2003
Do you not backup your machine/directories/work ???

Would start looking at restoring from the backups (if you have any).

Otherwise, I suspect that you're going to have to start from scratch again.
# 3  
Old 08-27-2003
I agree with Cameron, backups are the way to go in UNIX.

There is no undelete command that runs in UNIX. DOS runs differently than UNIX. Unix, there are processes running all the time, and once you deleted that space, its fair game to be written over by another process. So it is possible that your file area has been written over by process data tens or hundreds of times.

I know its very frustrating...

If no backup system is in place, get one! If you can't then do something like

1. Make a dir called /deleteditems
2. Instead of using rm, use mv [filename/dir] /deleteditems
3. Have a script that runs rm on any file that has been placed in the /deletedfiles that has been in that dir for 10 days or whatever time period you may like.
# 4  
Old 08-27-2003
Contrary to popular beleif it IS possible to recover lost files in Unix - well with a few caveats.....

FIRST STOP!!!! Dont run the machine anymore.
Turn it OFF.

If you need to work or correspond with people while you recover your files find another box to do it on.

As Oliie says the unlinked file area is now vunerable to being overwritten and losing the data foerever. The good news is that if you just deleted them they inodes are probably in an area that hasn't been reused yet.

Next step is to get the Coroners Toolkit.

If you have some space on the disk where your data was stored that isn't in a partition, make a new partition, install a minimal OS and compile the binary of CT for your hardware. Now move that binary to a removeable device and mount it on your damaged OS. FOLLOW THE INSTRUCTIONS VERY CAREFULLY.

Its a long process, complicated and far too much to go into here. It involves icat, finding parts of the masterblock etc. Your best hope is that all the files were under one directory.

I did for someone a year or so back...with limited success I must admit. Its certainly less work than rewriting 2 years of code. You might be able to find a partial recovery, perhaps the last working source file or something.

Good Luck

Last edited by andyj; 08-27-2003 at 09:45 AM..
# 5  
Old 08-27-2003
May be you can undelete it !!

Hi,

if you are using Linux, and ext2 or ext3 you can may be undelete the most of your files.

At www.linuxsysad.com you can download a Linux undelete HowTo, and most times you can recovery fresh rempved files.

But don't play/work with your system, every second working with your system will decrease the chance to get back the system.

regards
Alex
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Prevent admin user accidentally remove database files.

Hi Folks, Any system admin did provide AIX file system control to prevent user/ admin accidentally remove database files ? Thanks. (4 Replies)
Discussion started by: ckwan
4 Replies

2. Shell Programming and Scripting

Deleting files and directory's older than 3 months

I have a qnap TS259 that is running ubuntu. Have successfully setup back scripts that are initiated by cron. I would like to create a couple scrypts that would operate on the recycle bins for both drives. Just want to be able to run the script manually that would walk through both directories... (13 Replies)
Discussion started by: mackconsult
13 Replies

3. Shell Programming and Scripting

Shell : deleting only first 2 files in a directory

I have 4 files in a directory and want to delete only first 2 files only.. $ ls -ltr total 640 -rw-r--r-- 1 user other 148779 Oct 12 10:50 file1.xls -rw-r--r-- 1 user other 148779 Oct 12 10:50 file2.xls -rw-r--r-- 1 user other 148779 Oct 12 10:50 file3.xls... (4 Replies)
Discussion started by: giridhar276
4 Replies

4. Shell Programming and Scripting

AIX system.... deleting files in remote directory after retrieving files

Hi Friends, I am new to this , I am working on AIX system and my scenario is to retrive the files from remote system and remove the files from the remote system after retreving files. I can able to retrieve the files but Can't remove files in remote system. Please check my code and help me out... (3 Replies)
Discussion started by: vinayparakala
3 Replies

5. UNIX for Dummies Questions & Answers

deleting all the files inside a directory from a relative path

I have a file inside abc/def/ghi directory. let say a.txt I need to delete this a.txt from abc itself. I have tried ls /abc/def/ghi | xargs rm -r its saying rm: a.txt non-existent also tried rm -rf /def/ghi but in vein. plz help :) (2 Replies)
Discussion started by: gotam
2 Replies

6. Shell Programming and Scripting

Deleting the file only to all the directory and sub directory

I need the unix command or shell script to delete all the file in current directory and sub directory. (7 Replies)
Discussion started by: kingganesh04
7 Replies

7. Linux

deleting only directory not files

Hi Guys, I want to know wheather it is possible to delete directory not files, Example: In one directory there are 10 dirs and 100 files but my req is to delete only dirs not file Wheather it is possible ? (13 Replies)
Discussion started by: manoj.solaris
13 Replies

8. UNIX for Dummies Questions & Answers

deleting specific lines from all files in a directory

I have a directory full of text data files. Unfortunately I need to get rid of the 7th and 8th line from them all so that I can input them into a GIS application. I've used an awk script to do one at a time but due to the sheer number of files I need some kind of loop mechanism to automate... (3 Replies)
Discussion started by: vrms
3 Replies

9. Shell Programming and Scripting

deleting empty files in a directory

Hello Gurus, I want to delete only empty files (files with 0 bytes) at once from the local directory. Rightnow I need to go through all the files one by one manually and check the empty files before deleting them. Is there any unix command that finds and deletes empty files in a directory?... (5 Replies)
Discussion started by: berlin_germany
5 Replies

10. Shell Programming and Scripting

shell script: deleting files from a directory

i have the following problem: use shell script: Two directories have to be searched for files havin the same name. then delete these files from one of these directories. the directory names have to be accepted as command line arguments. what i have done till now is: 1. run a loop... (1 Reply)
Discussion started by: onlyc
1 Replies
Login or Register to Ask a Question