disaster recovery - did I do the right thing?

Martin Tournoij carpetsmoker at rwxrwxrwx.net
Sun May 6 03:24:33 UTC 2007


On Sat 05 May 2007 18:05, Garrett Cooper wrote:
> Martin Tournoij wrote:
> >On Sat 05 May 2007 17:05, Ray wrote:
> >>Hello all,
> >>I did something stupid the other day (sleep deprivation combined with a "clever" hack were the main reasons), and I'm just curious if I did 
> >>the right thing afterwards.
> >>
> >>The mistake:
> >>/usr/local/# rm -f *
> >>note that root was running bash as a shell at the time, found in /usr/local/bin or something.
> >>
> >>What I did was to start over, reinstall from scratch.
> >>my question, was there an easier way?
> >>thanks,
> >>Ray 
> >You can use pkg_info -ga to check for missing files in your packages.
> 
> For (t)csh:
> alias rm "rm -i"
> 
> For (ba)sh:
> alias rm="rm -i"
> 
> Now that you've learned :).
> 
> Martin's suggestion is good though -- would have done that considering that all that lived in /usr/local were ports.
> 
> -Garrett

The problem with this is that it will ask confirmation for every file it
deleted.
Which is gets pretty annoying after a while, also, if you delete a
directory containing a 100 files, you will have to press 'y' a 100
times.
This will probably lead to the habit of using 'rm -f', and/or simply
pressing y all the time without actually looking at the confirmation
message.
In any case, it's not likely to prevent any such accidents.

A better solution would be to write a script that would move files
instead of deleting them.
You should name this script to something else than rm, when you're
working with a new or "foreign" system, you will expect rm to move
files, instead of deleting them ... and we can all see another
disaster coming there...

Another hint would be the 'rmstar' option in tcsh, when set, tcsh will
ask confirmation before executing 'rm *'.

Note that aliasing 'cp' and 'mv' to 'cp -i' and 'mv -i' is an
*extremely* wise idea, in the past I have often accidentally overwritten
files that should not have been overwritten, leading to various
problems.

-- 
Regards,
Martin Tournoij


More information about the freebsd-questions mailing list