Sunday, April 29, 2012

Life after rm -rf

You just ran rm -rf ... for the ump...zillion...th time in your life and guess what, today you mistyped!!! What to do?
  • Identify your OS and see if there are proper recovery tools
  • Linux?
    • You're fudge'd! but there is hope ...
    • Do NOT quit your session (bash session, terminal window or remote ssh session), do NOT quit/exit it.
    • Use the history command and recreate your .bash_history file:
      history | cut -c 8- > ~/.bash_history
    • Use your wisdom of the ages to go through the compacted version of your history and recreate whatever you can.
      cp ~/.bash_history ~/.bash_history_backup
      awk ' !x[$0]++' ~/.bash_history > ~/noDuplicates
      mv ~/noDuplicates ~/.bash_history
    • If you were on an AWS image, rejoice! It will at least partially recover the basics of your home (~/) directory.
    • Set up daily snapshots and backup processes into place.
  • Mac?
    • There are some decent recovery tools like MacKeeper but chances are that by the time you download it, you'll end up overwriting disk sections that you wanted to recover.
    • Know when to give up on a lost cause, get out your blanky, assume the fetal position, suck on your thumb and cry to momma.

0 comments:

Post a Comment