Wednesday, September 24, 2008

Atlassian Backup chore

I was tasked with backing up Confluence and Jira. Sounds easy enough. They both have an XML backup that can be run automatically. The only problem, for me at least, is that the XML backup can take up a lot of space especially if you backup the attachments. On the last server we had, we actually ran out of drive space because the backups were just piling up.
So I decided to go a different route. The Atlassian folks actually recommend not using the XML backup anyway since it will eventually take too long or take too much space or could even become unstable. According to the documentation, all I needed to do was take a dump of the database and backup the Attachments directory.
I also wanted the backups to be run on a daily basis and wanted some way to monitor the backups. We use Hudson for our daily builds, so I wanted to use that for the backups. I also wanted to use Ruby (actually JRuby) to write the scripts. I really only wanted to use Ruby because it seemed cooler than writing a batch file.

I don't want this post to be too long so let me just go over the major issues and realizations from doing this little chore.

First of all, it took me a while to figure out how to get Hudson to run stuff on a remote machine. Basically you just need to create a free style project and then have the Job execute a Windows Batch file. Of course, nothing is that easy: If you run Ruby or a Batch file from Hudson, it assumes you are executing on the Hudson server and not on the remote machine.
I ended up using PSEXEC to enable Hudson to execute the program remotely. PSEXEC is an awesome tool that I've never heard about before. It just worked. How cool is that?
Anyway, after that find, it was just working out little kinks in the system. For example, PSEXEC did not like output streams when you run it from Hudson. It would give you an ERROR Code 1. To fix this, all you do is make sure your batch file has ECHO OFF at the top. PSEXEC would also hang when run from Hudson and I ended up putting an /accepteula switch to prevent it from hanging.

Secondly, I've come to the conclusion that Ruby ain't all that. I'm sure it is good for certain things, but just doing simple file manipulation (copying and zipping files) is just a pain. I had a hard time finding examples of copying directories and zipping files. And the ones that I did find didn't work. I ended up spending half my time trying to figure out how to do things in Ruby. Granted I don't know Ruby at all, but still, I would have thought examples for these simple tasks would be everywhere. So maybe Ruby is just not meant for those tasks. I ended up doing the script in a Batch file. Kind of ghetto, but it worked really well. Batch files may be a bit under rated.

So anyway, the chore is over. Everything works just the way I wanted it to work, with the exceptions of the tools that I ended up using. I think that's just the way things go sometimes. You need to roll with the punches and use the tools that fit the problem.

One final note. I obviously did not figure this out all by myself. It took a lot of Googling of the discussion boards, blogs, and all that good Internet stuff that is out there to find what I needed. Thanks to everyone that posted solutions to their problems because it sure helped me. I just wish I saved all those links so that I could give them proper credit for their work. I was working on an app that would help do just that...Shoebox v 0.1...maybe I should dust that one off and start working on it again.

Friday, September 19, 2008

Flex Graphics Library

I wanted to include custom graphic into my Flex application. I wanted to have something that I would be able to manipulate in code and also look the way I want it to look.
After some searching I found Degrafa. Degrafa is a graphics framework for Flex. It allows you to create custom, sophisticated graphics using the Flex markup language.

I haven't done too much with it yet, other than verifying that it works. I got it to display a simple circle in about 4 lines of Flex XML code. The only real problem, or inconvenience so far is that the graphics do not render in the Flex Builder designer. You need to compile the code and view it in the run-time application. I'm not sure if I'm doing something wrong or not, but at least it works.

This sample application that was done by Thomas Gonzalez for the 360 Flex conference in San Jose was done using Degrafa.



You can check out the working application here.