From owner-freebsd-questions@FreeBSD.ORG Tue Jul 5 10:27:46 2005 Return-Path: X-Original-To: FreeBSD-Questions@FreeBSD.ORG Delivered-To: FreeBSD-Questions@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A1D3116A41C for ; Tue, 5 Jul 2005 10:27:46 +0000 (GMT) (envelope-from xfb52@dial.pipex.com) Received: from smtp-out6.blueyonder.co.uk (smtp-out6.blueyonder.co.uk [195.188.213.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3CC2E43D46 for ; Tue, 5 Jul 2005 10:27:45 +0000 (GMT) (envelope-from xfb52@dial.pipex.com) Received: from [82.41.37.55] ([82.41.37.55]) by smtp-out6.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.6713); Tue, 5 Jul 2005 11:28:27 +0100 Message-ID: <42CA609F.3040701@dial.pipex.com> Date: Tue, 05 Jul 2005 11:27:43 +0100 From: Alex Zbyslaw User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-GB; rv:1.7.8) Gecko/20050530 X-Accept-Language: en, en-us, pl MIME-Version: 1.0 To: steve lasiter References: <20050704231717.88135.qmail@web33612.mail.mud.yahoo.com> In-Reply-To: <20050704231717.88135.qmail@web33612.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 05 Jul 2005 10:28:27.0169 (UTC) FILETIME=[47C7A110:01C5814C] Cc: FreeBSD-Questions@FreeBSD.ORG Subject: Re: accidental overwrite X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2005 10:27:46 -0000 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