Nrm - a recoverable deletion tool

What is it?

Nrm is a replacement for rm(1) that allows files to be easily recovered. Depending on your taste, you can either alias rm to nrm in your .bashrc file, or just call nrm directly when you need the protection.

How does it work?

The basic idea is to put deleted files into a hidden subdirectory named "./.gone" so that it stays near its original location in the filesystem. This avoids the problem of having multiple files of the same name colliding in a global "~/.trashcan" directory. This strategy also makes it easy to purge deleted files in just a subsection of the filetree.

How do the files eventually get cleaned up?

A simple cron(1) . job removes deleted files older than 3 days (a configurable number), and will also remove empty .gone directories.

Are there any other neat features of Nrm?

Yes. Nrm(1) comes with a scripts called ncp(1) and nmv(1) which are safe replacements for cp(1) and mv(1) and protect the user from overwriting a target file. Nrm also has facilities to provide sequenced backup copies of deleted files. Rather than just moving the file "foo" to "./.gone/foo", "Nrm -s" will time-stamp the save file with a name like "./gone/foo-93-05-09-21:32:17". This feature is handy for keeping check-point copies of engineering databases or critical documents. We have some of our CAD tools configured to nrm(1) the existing database before saving a new version. It's nice to be able to back out any change made over the last 3 days.

What is Nrm's design philosophy?

A large amount of effort went into making nrm(1) duplicate rm(1)'s error return codes, error messages, etc., under all the wierd corner cases of deleting sym-links, dev-files, etc.. Nrm(1) attempts to duplicate the GNU rm(1) command line options so that it can be seamlessly substituted for rm(1) in legacy scripts.

This program is the first line of defense allowing most non-super users to recover from simple errors without having to bother our back-up guru for a tape restore. I still would recommend behaving as if your rm(1) were a loaded gun, but if you still fumble it, then nrm(1) will make the reconstruction a lot easier.

Several heuristics were used in the code to make Nrm as fast as possible for most usages. In most cases, Nrm is very nearly as fast as just a rename(1) call. It does this by assuming first that "foo" is a regular file, and then falling back to more complex actions based on the initial error return code. This avoids an extra stat(1) under most common cases.

When time-stamping .gone files, Nrm uses a hash technique to avoid slow searches through the .gone directory.

Is there more detailed information available?

Sure. Check out the man page here .

Where can I get it?

A ~21kbyte compressed tar file is available here . Unpack with "zcat nrm.0.1.src.tar.Z | tar xvf -". After that, a "make" and a "make install" should get you going. You'll also need to manually create a cron job for root to periodically run the permanent cleanup script. See the README for more details.

How reliable is it?

Nrm has been in use for 10 years at Hewlett-Packard Labs on a cluster of about 25 HP-UX workstations. It has been running under Linux since 1997.

How is it licensed?

The entire package is hereby released under the terms of the GNU GPL. You are free to make modifications as long as you release source back to the community. For the present, I am happy to act as a coordinator to accept patches and enhancements to make sure they get folded back into the main source tree. If you'd like to help me build an RPM please send me email at the address below.

I hope you enjoy nrm, and that it saves you a bit of grief some day.


Rick Walker
rick_walker "AT" omnisterra.com