Results 1 to 5 of 5

Thread: Recovering deleted files

  1. #1
    Join Date
    Nov 2007
    Beans
    101

    Recovering deleted files

    I'm running Ubuntu Server LTS.... I was working on my server and deleted a user that had an html directory with my entire website. I need some help getting my php and html files back. No I didn't make a backup... but thats going to be the first step when I get it all working again. I'm curious if ubuntu Server has maybe a trash bin somewhere where the files could be stored. Any ideas and help is greatly appriciated...

    Thanks

    Rob

  2. #2
    Join Date
    Feb 2007
    Location
    Nagoya, Japan
    Beans
    343
    Distro
    Xubuntu 11.10 Oneiric Ocelot

    Re: Recovering deleted files

    What kind of filesystem are you using? (ext3, ext2, ...etc?) The default is ext3... so if that is the case, first, unmount the partition. In case you can't (because is root), then try using other HDD or a Linux live CD, and execute any of these two options:

    # Dump anything: (takes longer and generate large files)
    strings /dev/hda2 > big_text_file

    # other faster option (-50 means copy only 50 lines before/after)
    grep --binary-files=text -50 "textToSearch" /dev/hda2 > output

    Note: do not write anything to that partition until you recover all the important files.

    I hope it help you.
    Servers: Hardy(x4), Lucid(x6);
    Workstations: Quantal(x2), Lucid(x1);
    WM Flavors: Xubuntu(x3)
    Save Energy

  3. #3
    Join Date
    Nov 2007
    Beans
    101

    Re: Recovering deleted files

    Yes it is an ext3 however it is on a logical volume, does this make a difference?

    So if I understand correctly I would basicly run what you suggested from another installation or a live CD. Like I said in my post prior.. the help is greatly appriciated.

    I can't believe I was that dumb to delete what took me weeks to build. .PHP included.... well I guess this is the learning curve, a backup would be great right about now.

  4. #4
    Join Date
    Jan 2008
    Beans
    438

    Re: Recovering deleted files

    Boot from a LiveCd to make sure you don't overwrite anything on the server. If you've added any files since deleting the one file it's somewhat likely you may have overwritten it.
    While in the LiveCd, you want to install photorec, a file recovery program. It is included in the testdisk package.
    Next, attach another storage device to the server to recover files onto. (You can't save the recovered files onto the same file-system that they're being recovered off of because they'd get overwritten.)
    Then, start a terminal and type "sudo photorec" into it. It's pretty straight forward: pick the partition to recover from, pick the directory to save files to, and set it to only search free space.
    When it's done, all discovered files will be inside the directory you set. Note that their filenames are not the original, but guessed based off of their contents. The extensions should be somewhat close.

  5. #5
    Join Date
    Nov 2007
    Beans
    101

    Re: Recovering deleted files

    Well thank you both for the great information. Worked perfectly. File names didn't come in but I found everything I needed... and a lot more I might add....


    Now brings the question... what is the best alternative for backups. and so my search begins Thanks again, you'll never truely understand how much time that saved me....

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •