Last month a friend of mine had a disk failure. Fortunately most of his files are still in good shape. Right now, he is going through the difficult process of trying to recover what files he can. This task is extra difficult since Windows XP encrypts everything under the 'My Documents' folder so that other accounts and OS cant read them. If you are not doing regular backups, you are just asking for trouble.
For almost a year now, I've used a simple Ant script to backup my files. I use a very simple method of copying everything to a separate drive using Ant. The backup also has a few extras that require special steps. For example, backing up my subversion repository requires calling the subversion svnadmin hotcopy command. I've been happy with this process until I wanted to automate backing up data I have stored on the internet. For example, my bookmarks and address book are in yahoo. So I had to manually export them from yahoo to a file, then run my backup script. I looked at using Ant's 'Post' task to automate the web stuff, but I was really unhappy that it wasn't very nice code. Also it was hard to verify that everything worked correctly. If yahoo ever changed a page, the backup might stop getting my data and Ant wouldn't tell me.
So I decided to convert the backup to one of my favorite languages Ruby!
My first task was just a straight conversion of my Ant script to Ruby. The original Ant script was 122 lines of code. When I finished the Ruby version, it came to exactly 122 lines of code! Very funny! This completely surprised me. I had thought Ruby would take more lines of code than Ant. In Ruby I had to write a lengthy backup function (40 lines), and add a few convenience functions. However, when I finished the initial conversion they came out to exactly the same number of lines.
Right now I'm adding more advanced features to my script. Which I will blog about later.
No comments:
Post a Comment