There's no recycle bin

Gnome and KDE implement a recyle bin for the innevitable times when you delete something on accident. I feel more comfortable using a command line shell and so when I make these mistakes it hurts…a lot.

Last week I deleted a couple days worth of work. I had nearly finished implementing a driver and was working on organizing my subversion project for it. I hadn’t commited the code yet (big mistake) because I wanted to change file names before I imported it. That was really stupid because SVN allows you to efficiently and reasily change names of versioned files and to retain their change history.

I issued `svn add` to my directory of code. I noticed quite a few files that I didn’t want in the tree so I issued `svn rm`. SVN informed me that there were local modifications and so it was refusing to remove the directory. I then issued `svn rm –force` and the directory was deleted! I should have issued `svn revert` but I didn’t. I made a lot of mistakes that led to the lost of a few days of work.

I tried to use midnight commander to recover the files. Midnight Commander allows file recovery by changing to a special directory (cd /#undel:/dev/hda1 for example). Unfortunately Fedora Core used LVM and the actual block device was /dev/mapper/blah-blah-blah and Midnight Commander requires the device to be exactly under dev. I made a sym-link and tried again. I could see deleted inodes but I couldn’t view the contents nor could I save the inodes. Another mistake I made was that I didn’t immediately unmount the affected file system.

Next I rebooted using Fedora’s Rescue CD (disc 1 of the install set, bott using `linux rescue`). That included a copy of debugfs which also allows you to list, view, and copy deleted inodes. I was able to view the inodes with debugfs but unfortunately the files I needed were nowhere to be seen. I stayed late on a Friday night to redo the work I had lost.

On Saturday a friend reminded me just how stupid I was. I’m an emacs user and I have emacs configured to keep multiple backup copies of files. I can’t stand the default behavior of leaving the backup files in the current directory so I save them to ~/.saves. On Sunday I went into work and found the file(s) that I needed. In the end most of the lost time was me trying to undelete files.

The code relevant to have emacs save files in ~/.saves is:

backup-by-copying t
;; don't litter ~ backup files all over the place
backup-directory-alist '(("." . "~/.saves"))
;; get rid of old crap with out bugging me
delete-old-versions t
;; a little version control, keep 2 most recent
kept-new-versions 2
;; version control for backup files
version-control t)
This entry was posted in Geek. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s