I am working on Ubuntu 10.04 version.
I accidentally deleted my code from find -delete command.
Is there any way to recover the data?
Many thanks in advance.
This question came from our site for professional and enthusiast programmers.
Restore from backup. If you don't make regular backups, then sooner or later something like this will happen and you will lose data.
If you do a google for undelete linux, you will find a method of finding deleted file entries, however, while the system runs, there is every chance the space is overwritten. Having done something similar, in the end, I ended up using strings, and grep to extract the source from the disk, and then replacing a lot of the brackets and punctuation.
Undelete usually occurs on systems where they dont delete the file, they move it and hide it aka windows, unix was not designed to be that kind of system.
This works on ext2 (and is the method I mentioned to start with http://e2undel.sourceforge.net/recovery-howto.html) however, do be aware, it may not work.
Best way to get deleted files back on unix is to restore from a backup.
While it is possible (at least some parts) as already @BugFinder told. But for the future:
The first thing what you should do - remember it:
Immediately turn off your computer.
If you don't run mission critical database, the best is turning off from a power and not by regular
Ofc, you will get corrupted filesystem, but usually can repair it without problems (fsck) and you will do some voo-doo filesystem hacking with fsdb anyway... ;)
Backup frequently is a good idea, or use more intelligent OS/Filesystem combination. For example FreeBSD/ZFS. (I don't want start any flamewar, so please don't comment my last line). :)