accidental overwrite
Alex Zbyslaw
xfb52 at dial.pipex.com
Tue Jul 5 10:27:46 GMT 2005
steve lasiter wrote:
>until today when I tried to copy over a .sql file so
>MySQL could see it and run it. I accidentally copied
>it over to /usr/local/bin/mysql thinking mysql was a
>directory.
>
>
>My question(s) are: Is there any way to revert back to
>the original file if this type of mistake is made?
>
>
Anyone, running any computer with any operating system who does not keep
backups is asking for trouble. FreeBSD is no different to anything else
in that regard. In this case you destroyed a file which has virtual
backup in the form of the Internet. Recover it by re-installing the
package.
Some simple rules you could follow to try and avoid doing this again:
1) Don't do something as root unless you have to.
2) Explore the -i options to cp, mv and rm and set them up as aliases
for your own account and for root. This is not foolproof because there
are dozens of utilities which can also overwrite files (tar, rsync,
rdist, scp, cpio to name a few).
3) Explore options your shell might have to avoid overwriting files.
E.g. tcsh has noclobber and you shell will have something similar.
4) Modern shells have command-line expansion. Use it to expand the
target of your cp to see if it already exists or not, is a directory or
not etc.
5) Unix of any kind is the single most complicated "thing" you will ever
use in your life. Buy a book; read the handbook; read manual pages.
Learn about it and you can hopefully minimise the mistakes.
6) Make backups regularly. Not everything is on the internet. There
are many options from CDs, through flash sticks, to tapes and
autochangers. You can add another disk to your PC or to another PC.
You can do more than of these. You should use them regularly if you
consider your data to be precious.
--Alex
More information about the freebsd-questions
mailing list