Ba-leated!
Sometimes I suck. Yesterday was one of those times. By flagrant misuse of “rm -r” I managed to delete the past two months of Michael’s wonderful photos and uploaded images. Actually I wiped out his entire blog, images and some of his gallery but through movabletype and an old back up I was able to restore most of it.
The annoying part is that at the time of said flagrant misuse I was reading about this replacement rm [ via raelity bytes ] that makes the unix rm command work more like the MacOSX Trash. Instead of deleting anything out right it moves it to ~/.Trash/ instead. Which is the same place OSX keeps your trash.
I liked the idea but it wasn’t exactly what I was looking for, but with a little googling and guessing at the content of japanese webpages I found a wonderful little Safe ‘rm’ Script It’s actually a collection of perl scripts.
- trash emulates the rm command but instead of killing files dead it packages them in nice little dated and timed .tar archives and moves them to ~/.Trash/
- undel undeletes! It reverses the last trash action. Puts everything back unscathed. Run it again and it reverses the next previous trashing. Any file can also be undelted by hand.
- autoemptytrash checks in files in ~/.Trash/ and if they were put there by trash it checks to see if they are over 12hours old and if they are permanently deletes them.
Just put them in ~/bin/, make them executable and add this to your .login:
alias rm=~/bin/trash # makes you use trash instead of rm
alias del=/bin/rm # lets you still rm.
alias emptytrash=/bin/rm ~/.Trash/* # lets you manually emtpy the trash
Then add ~/bin/autoemptytrash to your crontab to run every hour and life is much much safer.
I set this up locally and on mintchaos.com. Join us tomorrow when we explore options to routinely and automatically back up webservers.
Xian 06:24 PM, 04.13.03 - p-link
Comments: Ba-leated!
Post a Comment: