Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .