I was logged in as root for reasons which seemed convenient at the time: weird file permissions, the need to change ownership of various files, etc. In retrospect, I should have gone through the "trouble" of using FTP.
As for the code-on-the-clipboard accident, I would advise just blanking your clipboard when using the terminal window (i.e., copy some trivial text). I did not mean to paste the clipboard contents. It was the opening /**\n of the javadoc-style comment on my clipboard and the proximity of ctrl-v to shift-v that caused the disaster. sigh.
I would also advise playing with disaster scenarios to evaluate your recovery scheme. It's probably not as good as you'd like.