Kristian Lunde

Archive for the ‘Mac’ Category

Automated backups with Amazon S3

with 3 comments

I recently decided that I my half hearted backups to an external drive wasn’t really good enough, so I started to look at alternatives.

Note, this howto is for Mac and *nix system, if you need a windows version please try to google it.

I tried Crash plan, considered a extended dropbox plan but none of them seemed like the correct solution (still I love dropbox, its a great app). I ended up registering an Amazon S3 account.

After a quick google search I found this brilliant little blog post “Using Amazon S3 for personal backups” which describe how to use jetS3t to semi automate the synchronization of the iPhoto library on a Mac OSX.

I am not going to repeat the instructions found on the “Using Amazon S3 for personal backups” blog post, I did however have to do a few minor tweaks to get it to work, I also extended the functionality slightly, to enable a fully automated backup solution.

JetS3t has had a few releases since the “Using Amazon S3 for personal backups” article was written, I downloaded Adding the link of the jetS3t directory to the path in .profile didn’t work for me (I’m on Mac osX 10.6), so I added it to my .bash_profile file. You can find .bash_profile in /Users/YOUR-USERNAME/, you’ll have to replace YOUR-USERNAME with your proper username of course. Other than that I followed the examples in “Using Amazon S3 for personal backups”.

Once that was in place and worked properly I started to add some custom scripts.

1. Create a scripts directory in your home directory
2. Create a logs directory in the scripts directory

  1.  cd
  2. mkdir scripts
  3. mkdir scripts/logs

2. Navigate to your scripts directory and create a file.

  1. cd scripts
  2. touch

3. Use your favourite text editor to add the following code to the script

  1. #!/bin/bash
  3. #Backup iPhoto
  4. UP YOUR-IPHOTO-BUCKET /Users/YOUR-USERNAME/Pictures/iPhoto\ Library >> logs/amazon-s3-iphoto-backup.log
  6. #Backup Documents
  7. UP YOUR-DOCUMENTS-BUCKET /Users/YOUR-USERNAME/Documents >> logs/amazon-s3-document-backup.log

Replace YOUR-IPHOTO-BUCKET with the amazon S3 bucket you want to use, and replace YOUR-USERNAME with your username on your mac or *nix system. We pipe the output from the sync process to files in the logs directory, one log file for the iphoto and one log file for the documents process.

4. Edit your crontab. The crontab is a file where you can add files that you want to automatically execute on a regular basis.

  1. crontab -e

5. Add the script to your crontab, I’ve chosen to run it once a week at 20:00 every Sunday, which is expressed by (0 20 * * 0).

  1.  0 20 *  * 0 /Users/<em>YOUR-USERNAME</em>/scripts/

6. Save your cronjob

There you go, now you’ll backup your iPhoto library and Documents every Sunday at 20:00 as long as your computer is turned on and online. You can of course tweak when and how often you want to sync to Amazon S3, you can read more about scheduling cron jobs at wikipedia

Written by Kristian Lunde

May 21st, 2011 at 9:04 pm

Posted in Mac,Misc,Real Life

Tagged with , ,

Installing Cassandra and Thrift on OSX

with 4 comments

Note that this installation description was written for Cassandra 0.5 and may not be correct for the current releases.

Cassandra is a NoSQL distributed database developed by Facebook, it is built to handle huge amounts of data and to perform CRUD operations quickly. The Cassandra site’s strap line says:

“The Apache Cassandra Project develops a highly scalable second-generation distributed database, bringing together Dynamo’s fully distributed design and Bigtable’s ColumnFamily-based data model.

Thrift is also developed by Facebook and is a software framework for service development and is used as an interface to Cassandra. The Thrift page site says:

“Thrift is a software framework for scalable cross-language services development. It combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, Smalltalk, and OCaml.”

Both Cassandra and Thrift are apache incubator projects.

Installing Cassandra

1. Download cassandra

Download from:

2. Create and set the correct paths in the storage-conf.xml

You can find the storage-conf.xml file in your cassandra root directory /conf

My configuration file settings in storage-conf.xml:

  1.   <CommitLogDirectory>/Users/kristianlunde/tmp/cassandra-log/commitlog</CommitLogDirectory>
  2.   <DataFileDirectories>
  3.       <DataFileDirectory>/Users/kristianlunde/workspaces/mysapient/cassandra/data</DataFileDirectory>
  4.   </DataFileDirectories>
  5.   <CalloutLocation>/Users/kristianlunde/workspaces/mysapient/cassandra/callouts</CalloutLocation>
  6.   <BootstrapFileDirectory>/Users/kristianlunde/workspaces/mysapient/cassandra/bootstrap</BootstrapFileDirectory>
  7.   <StagingFileDirectory>/Users/kristianlunde/workspaces/mysapient/cassandra/staging</StagingFileDirectory>

Notice: You have to create all these directories for cassandra to run properly.

3. Set a log directory in the file

This file is found in the same directory as the storage-conf.xml

4. Check that you are running java 6 as default

  1.  java -version

If you are running an earlier version of java you will have to change your version. Java 6 should already be installed on your mac if you keep your os in sync with the automatic updates from apple. You can change your java version by using the “Java Settings” application located in your /Application/Utilities directory.

5. Starting Cassandra

You should be ready to go now, navigate to the root directory of your cassandra installation and start cassandra by typing:

  1. bin/cassandra -f

If you dont see any error messages cassandra is probably running as it should, so it is time to test it out.

Cassandra comes with a CLI interface which allowes you to do simple queries to the database. Notice that the CLI interface is not not as powerful as the thrift interface. You can for instance not execute get queries in Super Columns, those queries will create a java exception.

To test the CLI interface, run the following command from the cassandra root directory:

  1. ./bin/cassandra-cli –host localhost –port 9160

Inserting values to the keyspace:

  1.  cassandra> set Keyspace1.Standard1['blog-post']['name'] = 'Installing Cassandra and Thrift OSX'
  2.  Value inserted.
  3.  cassandra> set Keyspace1.Standard1['blog-post']['author'] = 'Kristian Lunde'
  4.  Value inserted.

Retrieving data from the keyspace:

cassandra> get Keyspace1.Standard1['blog-post']
  1.    (column=name, value=Installing Cassandra and Thrift OSX; timestamp=1258748376097)
  2.    (column=author, value=Kristian Lunde; timestamp=1258748405486)
  3.  Returned 2 rows.
  4.  cassandra>

Installing Thrift

Update: I found this manual after I had installed thrift:, using this install guide will probably fix the issues I had with compiling thrift.

1. Download Thrift

Download from and extract it.

2. Check that you have installed the following:

  • g++ 3.3.5+
  • Runtime libraries for lex and yacc might be needed for the compiler.
  • boost 1.33.1+ (1.34.0 for building all tests)

I had to install boost manually:

  1. sudo port install boost

Notice: the boost installation might take a while, It took about 5 – 10 minutes on my Macbook PRO (2.53GHz).

You can see the full requirements for thrift at

3. Start the installation

  1.  kristian-lundes-macbook-pro:thrift kristianlunde$ ./
  2. installing `./missing'
  3. installing `./install-sh'
  4.  compiler/cpp/ installing `./depcomp'
  5. installing `./ylwrap'
  6.  kristian-lundes-macbook-pro:thrift
  1. ./configure

This ended up in an error message for me:

  1.  ./configure: line 20722: syntax error near unexpected token `MONO,'
  2. ./configure: line 20722: `  PKG_CHECK_MODULES(MONO, mono >= 2.0.0, net_3_5=yes, net_3_5=no)'

To fix this I had to copy my pkg.m4 file from /opt/local/share/aclocal/pkg.m4 to my thrift/aclocal directory.

Navigate to your thrift root directory:

  1.  cp /opt/local/share/aclocal/pkg.m4 aclocal

Thanks to and for pointing me in the right direction.

You should now be ready to run make

  1. make


  1. sudo make install

You should now be able to run thrift on your mac.

  1. thrift

You should now be ready to build your amazing application with Cassandra if both your installation of Cassandra and Thrift were successful.

I will try to post another blog post shortly on using Cassandra, Thrift and PHP. Stay tuned.


Written by Kristian Lunde

November 20th, 2009 at 9:39 pm

Posted in Mac,NoSQL,web

Tagged with ,

Installing nutch 1.0 on OSX

with 2 comments

Today I started to work on a little project that required a crawler, and Nutch seemed to do most of what I needed. The nutch team conveniently released Nutch 1.0 late in March 2009, so I had a brand new release to test out. Installing nutch 1.0 on a mac is not as straight forward as I thought, I ran into a lot of unexpected issues and here is my cook book description of how to successfully install nutch 1.0 on your mac.

  1. Download the latest source code from the Apache SVN repository I tried running it from the tarball without success, I also tried to compile the source from the tarball, but a post on the nutch forum clearly states that this will not work.
  2. Set your JAVA_HOME and NUTCH_JAVA_HOME variables, again this is not straight forward, they both need to point to your real installation of Java 1.6 (earlier versions of Java will fail). I sat these variables to: /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home, I could not get the /Library/Java/Home symbolic link to work properly.
  3. Compile the source code using Ant (I built it in Eclipse).
  4. Setup your nutch configuration, by following the tutorial by Peter P. Wang
  5. Run your first crawl with: ./bin/nutch crawl urls -dir crawl -depth 3 -topN 50

Most of the issues I encountered was related to the Java version and the fact that using /Application/Utilities/Java/Java preferences application do not really change the JAVA_HOME directory /Library/Java/Home properly. So make sure you have set both JAVA_HOME and NUTCH_JAVA_HOME, and that your OSX does not fool you when it pretend to be symbolically linking to the 1.6 installation.

Good luck.

Written by Kristian Lunde

April 7th, 2009 at 9:15 pm

Posted in Java,Mac

Tagged with , ,

2.5 applications I really miss in OS X

with 3 comments

In a previous post I wrote about my new life running on a MacBook Pro and OSX. It has now been over a month since I switch over to this unix hybrid, and I am quite liking it. It is very stable, I almost never turn off my mac, but I put it to sleep, this is working fine and my last reboot is over two weeks ago. I have also gotten used to some of the new weird keys on the keyboard and the shortcuts, but I am not yet as efficent on a mac as I am/were on ubuntu/windows. During the last few weeks I have discovered that Apple and other in most cases provide me with the applications I need, but not always, and here is the list of applications I really miss:

1. TortoiseSVN
Windows application which integrates itself with Windows Explorer and provide a SVN client. I would say that this is the best graphical SVN client I have ever used. SVNX which I currently use on the mac is not a very good replacement.

2. Kate / Notepad++
Kate is a KDE text editor for unix based systems. Notpad++ is Kates equivalent on Windows. Both editors provide a simple and intuitive user interface, and a lot of syntax highlight files for all the obscure programming languages you can think of.
I know Mac have the TextMate application, but that is third party software and you have to pay €48 or something for a license, and that is probably what I probably will do. The TextMate application is really good and provide most if not all the functionality that Kate and Notepad++ provide.

In my desperation for a good text editor I almost went off and tried to install KDE on Mac, but that was said to be experimental and could break my entire system. So that is a no go for now. The article however was really interesting:


I still miss my ubuntu system and will probably go off and install parallels or vmware and ubuntu, just to have it accessible :)

Written by Kristian Lunde

December 3rd, 2008 at 11:51 pm

Posted in Mac,Ubuntu

Tagged with , , , ,

Porting to Mac

with 4 comments

At Orange Bus we all work on MacBook Pro, and when I started up at Orange Bus it was the very first time I used a Mac and OS X. It is now 12 days since that first experience with an Apple computer and though I am still a bit unfamiliar with certain features I am getting in to it, and I really like it. The stuff that I have most problem with are:

The keyboard
I have some trouble finding the keys and key combinations I am used to from both Ubuntu and WinXP. And it probably does not help that the keyboard on the laptop is English, and my external keyboard at work is Norwegian (I was thinking it would be a good idea to bring a Norwegian keyboard to the UK, yeah right).

Changing windows
Moving between different set of windows and the different set of their instances are still a bit unfamiliar. In particular moving between a set of windows of the same application.

Universal access
Universal access is a piece of software which enhances for instance the readability on the Mac, and the key command to activating the speach on the mac must be some command I am used to from Windows or Ubuntu. I am always turning it on, very annoying.

That was the “negative” part about Mac, but that is just things I need to learn. Now let us have a look at the positive stuff in OS X.

I have heard it a million times by mac users, it is so easy to use a mac but I have never really believed them. But they are correct. Using a mac is extremely simple, Apple must have some of the best UI designers in the world. Everything is so amazingly simple. And another thing you just have to love in OS X is how you install software. You open the install file and drag it into the Application folder, and woosh, the application is installed. I would go as far to say that if you are a novice computer user, Mac would probably be the best choice. Lets compare it to moving around. Using a mac is not much harder than walking, in comparison to Microsoft Windows which would be something like controlling a space shuttle.

Well I have been praising Mac for their simplicity right now, but even though it is very easy to use you still have the possibility to do advanced stuff. For instance, since Mac is based on Unix you have a terminal easily accessible and you can use almost all your regular commands :D

Mail is a Mac application for managing….. yes you are right, mail. Well Mail is a okay application it works fine, but it is not as good as Microsoft Outlook, but it is yet another example of how simple and intuitive an Apple product can be.

Quicksilver is a third party software for easy launch of applications. Type “ctrl” + “space” and then start typing the name of the application you want to launch, it automatically find the application and launches it when you hit enter. Brilliant!

At this point I can not see one good reason for going back to MS Windows. I am still very fond of Linux distros like Ubuntu, but Mac and OS X have really impressed me. So I suppose I have to line in with all the other Mac fanatics now (no I am not a mac fanatic, at least not yet).

Written by Kristian Lunde

November 15th, 2008 at 1:55 am

Posted in Apple,Mac

Tagged with ,

Get Adobe Flash player