dlostboy (at) lostinfo (dot) com 

Home | Journal | Multimedia | Files | Other | Links | About

      How I was able to "undelete" a text file that I lost

I was working on a script to help me edit my Apache configuration when it went haywire and erased the entire file. I checked my backup and for one reason or another I didn't have one. So with the help of my friend Thomas, I was reminded that everything in UNIX is considered a file, including the drives and partitions. I also learned of a program called "strings" that will pull strings out of binary files. Lets assume that ad0s1e is the partion I need to recover something from...So....

  • strings /dev/ad0s1e > bigfile.txt

  • Which will make a file almost as large as that partition on your PC. Be sure not to write it to the partition you are trying to save or else you may overwrite the data you are trying to save now that it's unallocated. Now I knew what I needed was the VirtualHost directives. So I used grep to parse the file:
  • grep -A 8 VirtualHost bigfile.txt

  • That would cause it to find "VirtualHost" in the file and then return it and the 8 lines afterwards to me. Took awhile but I got all the info i needed to recreate my apache.conf!
     
     

      ©2000, ©2001 LostInformation