Find the answer to your Linux question:
Results 1 to 7 of 7
In ~/bash.profile, i'm sourcing a file that sets the variable $fb to the folder of my file backups. With a shell script, i'd always rm -rf $fb/* , before having ...
  1. #1
    Just Joined!
    Join Date
    Sep 2009
    Posts
    26

    Accidental rm -rf *

    In ~/bash.profile, i'm sourcing a file that sets the variable $fb to the folder of my file backups.

    With a shell script, i'd always rm -rf $fb/*, before having the script cp -r the new files to $fb.

    Today, just shortly after switching to zsh, and forgetting to set up my aliases and variables, i've run the backup script.

    So it tries to rm -rf $fb/*, but $fb has no value...

    Fukc my life.

    It was a small Arch system on sdx2 of my flash stick.
    Actually i'm damn happy i've ^C'ed before it began with /mnt/, as absolutely ALL of my storage devices were mounted. Doing an ls on the partition, i see the first directory being /dev/; and /mnt/ comes right after that...

    Doing a fresh start won't bee too bad actually. I'm a noob and had started using Arch partially to learn more. It had some minor problems i never got. (Although i'm in love with Arch now. Will probably use no other until the day i make my own distro. =P)

    Have a good day everyone, and look out for valueless variables!

  2. #2
    Linux Engineer Freston's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    1,047
    One of the geeks here will probably know better from memory than I how you might be able to restore your data, if you wish to give it some effort. I'm thinking `dd` here, but am not sure.

    So let me suffice to say I'm sorry for you. But don't worry; welcome to the club! We've all been there. '*nix doesn't prevent you from doing stupid things, as that would prevent you from doing clever things'. I am sure you do it never again




    Oh, and the way your script is written, that was asking for trouble

    This would have prevented it:
    Code:
    if [ $fb ] ; then
       rm -rf $fb/*
    else
       echo 'FAIL! Variable $fb unset!'
       exit
    fi
    Can't tell an OS by it's GUI

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,955
    Welcome to the world of Homerisms - doh! It hurts when I do that! I too have inadvertently done the "rm -rf *" from the root directory, as root... The sound your hear is my head banging against the wall, repeatedly. Truly an "Oh, sh!t" moment. My sympathies, and hope that you have a recent system backup...
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  4. #4
    Just Joined!
    Join Date
    Sep 2009
    Posts
    26
    Yeah, the script was indeed looking for trouble.

    Actually if you look at it, it's an rm -rf /* and not just *, which would only have wiped out the directory i was in...


    But...

    My mind was seemingly too dizzy yesterday, and i just realized it HAS touched /mnt/.
    God oh why has it started from sd2 while 0 and 1 are untouched?
    44 GiBs of music and movies worth another 20 GiBs are gone. ._.

    I'll try data recovery.

  5. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,955
    If it is an ext2/ext3 file system and you haven't written anything to it yet, you might be able to undelete the files. There are 2 utilities that work (sort of) - e2undel and ext3undel. If you are running a RedHat-based distribution (RHEL, Fedora, CentOS, et al) then you should be able to find them on the rpmforge package list or web site (I think). I have them installed on my CentOS system and they have been useful for me in the past to restore data files. I haven't tried entire directory trees however...

    Try here if necessary: ext3undel
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #6
    Just Joined!
    Join Date
    Sep 2009
    Posts
    26
    Ah, thanks for the help, but no it's NTFS. And trying out some freeware, i can't seem to get much useful results. The partition was probably too heavily fragmanted. Damn NTFS...

  7. #7
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,955
    Quote Originally Posted by TaylanUB View Post
    Ah, thanks for the help, but no it's NTFS. And trying out some freeware, i can't seem to get much useful results. The partition was probably too heavily fragmanted. Damn NTFS...
    I think you'd have to boot Windows and try some NTFS recovery tools there. Good luck.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

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