Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Like I said, I moved a bunch of sql files but instead of moving them to a directory I seem to have renamed them and put them all in the root directory as one file named "newfolder"

Can I undo this or have I royally boned myself?

share|improve this question
1  
If you ran mv filename.sql /newfolder you didn't rename more than one file. Just run mv /newfolder filename.sql to revert. –  slhck Mar 6 '13 at 6:32
    
I ran it a bunch of times without checking. So I ran "mv filename1.sql /newfolder" then "mv filename2.sql /newfolder" then "mv filename3.sql /newfolder". So I overwrote the file a bunch of times. It it at all possible to fix. –  GUYMESSEDUP Mar 6 '13 at 6:40

1 Answer 1

If you ran mv file1 newfile and then mv file2 newfile, you irreversibly overwrote newfile. This means your first file is gone.

Practically, there's not a lot you can do in that situation.

Your best option is restoring from your regular backup. You can also pull new SQL dumps, or stop using the system right now and try a file undelete tool. There are plenty for NTFS and FAT, but not that many for ext filesystems. See also:

Also, when working as root, I'd recommend setting the following aliases in your shell's configuration file. This way, you will be prompted before overwriting existing files or removing any file.

[ $UID = 0 ] && \
  alias rm='rm -i' && \
  alias mv='mv -i' && \
  alias cp='cp -i'

Setting aliases for basic commands might bite you at some point if you're getting too used to them, but if you always want a quick reminder before doing potentially harmful stuff, that's the easiest way.

share|improve this answer
    
I guess I really messed up here. For the moment I've made new dumps but having the dumps from previous dates were what was important in this case. I don't handle the backups and I'm hoping my coworker has recent ones. Thank you very much for the help. –  GUYMESSEDUP Mar 6 '13 at 7:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.