16 October 2007

erasures without consequence

Today I got rid of some files that were not intended for removal. Had been long since last such mistake. Lapse happened immediately after user switch:

user@host ~ $ su
host user # rm -rf tmp

Deletion of '/root/tmp' was intended but 'su' in place of 'su -' did not switch working directory and deletion of '/home/user/tmp'
began instead. Truly trivial. Surely it has happened many times before.

Since this was my own 'tmp' folder that contains both useless and useful crap I desired to know whether anything worth rescuing was really lost1. Quite unexpectedly user switching proved very useful for identifying lost files:

user@host ~ $ locate --version
Secure Locate 2.7 - Released January 24, 2003


user@host ~ $ su -
host ~ # locate /home/user/tmp > /home/user/rootview.txt
host ~ # exit
user@host ~ $ locate /home/user/tmp > userview.txt
user@host ~ $ diff rootview.txt userview.txt | grep "<" > lost.txt
user@host ~ $ wc -l lost.txt
1490 lost.txt

1490 lost files is quite a big number. But those did not contain my life. Just pieces of others' lives. Pictures of weddings I did not attend and vCards of people who I had no intention of contacting. No problem.

1—No, I don't do backups. Someday will. Really.
2—Secure Locate is a replacement for GNU Locate. Secure Locate indexes entire filesystem into database, but to non-privileged users it only shows the files that they currently can see.

No comments: