undo rm -rf *

Patrick O'Callaghan pocallaghan at gmail.com
Fri Mar 29 02:55:27 UTC 2013

On Wed, 2013-03-27 at 23:58 -0700, Rick Walker wrote:
> > > I'm not a fan of trash directories.  They give you a second chance, but
> > > you may end up not really deleting things you wanted to delete.  What
> > > about a simple script something like this?  
> If you want something a bit more polished, you might check out
> "nrm", available  at http://www.omnisterra.com/walker/linux/nrm.html
> It's a C program written to have the same arguments, return codes and
> side effects as /bin/rm to the extent possible. 
> It moves files into the hidden sub-directory ".gone" instead of removing
> files.  You can remove files with "-s" and you get sequenced backups -
> all files are saved with a time-stamp suffix for fine grained file
> restores.  There is a program "urm" to unremove the file, but most users
> just do "ls .gone" to see what they've recently removed and then just
> "mv" it back to their working directory. 
> There is an associated cron job that runs every day to permanently
> remove all deleted files that are older than a configurable age.
> The default is 3 days so you can get things back on Monday that you nuked
> on Friday. 

I prefer to run a daily cron job to back up my home directory, which
also allows me to look back over previous versions. I happen to use
rsnapshot for this, but plenty pf other solutions exist. At some point a
pseudo-rm is going to fail, either because the implementer didn't handle
some corner case correctly, or because you typed rm instead of nrm, or
because a file was removed by a program without anyone typing anything,
and the only solution is to have a backup. So if you're going to have a
backup anyway, what's the point?


More information about the users mailing list