LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Restoring files that has been deleted (https://www.linuxquestions.org/questions/linux-newbie-8/restoring-files-that-has-been-deleted-629088/)

andreas_skw 03-18-2008 10:17 PM

Restoring files that has been deleted
 
How can i restore files that i has been deleted? Really, it was an accident... Anyone can help me?

powen 03-18-2008 10:55 PM

Restore a deleted file
 
Hi,
I assume it was removed via rm or rm -rf?
There is no way ( that I know of ) to recover from that if you have turned off the computer. This is because any inode links will have been aged out and no longer available. In that case if you have a backup somewhere then that is the only recovery method available.

If your computer and session is still available where you did the delete then you could use: lsof
there should be a process id still available:
On command line issue:

$ lsof | grep filename( the one you deleted )

Assuming this came back with a value then you are in with a chance to recover.
in /proc there will be a file with the same process id number returned in above.

$ ls -l /proc/<pid>/..
$ cp /proc/<pid>/../<number> filename.recover
$ cmp filename.recover filename.orig ( whatever you really called it )

Assuming no complaints from cmp then you are back in business.

Tips:
1. check out man lsof or even google it
2. If using rm use the -i switch to ensure you are prompted before the delete actually occurs.
3. These days storage is so cheap so I often find it better to just compress zip and archive stuff i no longer want. Then if after nn years I still dont want it then delete...

good luck and cheers

jschiwal 03-18-2008 11:07 PM

You could start by indicating the filesystem that the files were on.

Then search on Google with that filesystem (e.g. fat32 or ext3) and the terms "undelete".

If another process doesn't have a lock on the file, then a program will need to locate the file from the filesystem and attempt to recover it. Such a program needs to understand the filesystem to be able to do this.

If the files are very important, you may want to create an image of the filesystem while it is off-line and then try to recover the files from the image file. This will prevent further writes from overwriting files.

If they were older files, the easiest way to recover them is by restoring them from your last backup.

andreas_skw 03-19-2008 10:38 PM

unfortunately, i've turned off my computer >_<. I did it via rmdir <files> -Rvf. Thanks for powen. I'll careful for the next time. And forjschiwal, i'll try your suggest. I'll report to you as soon as i do that.


All times are GMT -5. The time now is 12:58 PM.