Backup Your CVS/SVN Repository to Amazon S3

Recently I decided to implement one additional layer of protection for our CVS repository. It was only backed up to another folder on the same server,
the same virtual disk (RAID 0). “Why not use Amazon S3 storage for additional protection?”,- I thought.

Step 1: Compile FUSE support into the kernel and install s3fs
Step 2: Mount S3 bucket to a local folder on the server. To achieve this create a file /etc/passwd-s3fs and put your Access Key and Secret Access keyseparated by the colon there.
Step 3: Edit your fstab and put the following line there:
s3fs#your_bucket_name       /mnt/s3_storage       fuse    auto            0 0

This script leaves only the most recent copy of the backup in the BACKUPSDIR and 7 copies (for 7 days in a row) on the remote storage. All backups on the remote storage are encrypted with your password. Don’t forget to change it (–passphrase pwd ). Enjoy!

#!/bin/bash
#
# Back up CVS
#
CVSDIR=/home/cvs
BACKUPSDIR=/home/andrew/backups
S3DIR=/mnt/s3_storage
#
# Get current date and time
set `date +"%Y %m %d %H %M"`

# Remove any backups older than 1 days
echo "Removing backups older than 1 days..."
TO_DELETE=$(find $BACKUPSDIR -atime +1 -name "cvstree*")

if [ -z "$TO_DELETE" ]; then
    echo "No backups to delete"
else
    # remove them!
    rm -f $TO_DELETE
fi

#echo "Backing up CVS tree..."
/bin/tar -cj -C $CVSDIR --totals . > $BACKUPSDIR/cvstree_$1-$2-$3.tar.bz

echo "Encrypting the backup"
/usr/bin/gpg -c --batch --passphrase pwd $BACKUPSDIR/cvstree_$1-$2-$3.tar.bz
echo "Moving to the remote storage"
/usr/bin/mv $BACKUPSDIR/cvstree_$1-$2-$3.tar.bz.gpg $S3DIR

# Remove any backups older than 7 days on the remote storage
echo "Removing backups older than 7 days from the remote storage..."
TO_DELETE=$(find $S3DIR -mtime +7 -name "cvstree*" )

if [ -z "$TO_DELETE" ]; then
    echo "No backups to delete"
else
    # remove them!
    rm -f $TO_DELETE
fi

exit 0

How To Create Passionate Users

Some time ago I found an annotation of the talk Kathy Sierra gave at (don’t remember which) conference. I’m republishing it here to spread the good knowledge. Read slowly, it is fantastic!

  • If we want to create passionate users, we need to help them get better.
    • ‘Nobody’s passionate about things they suck at.”
    • Many people still have their cameras permanently set on “P” – automatic mode — even though those cameras offer finer control over things like shutter speed and aperture
    • What would it mean to our users if we unlock the door and help them be awesome?
  • In Malcolm Gladwell’s book, Outliers, a major theme is the “10,000 Hour Rule”, which states that it takes about 10,000 hours of practice to become really good at something.
    • 10,000 is a long time – it’ can be a depressing prospect
    • [Joey: According to Outliers, 10,000 hours makes for about 3 hours of focused practice every day for 10 years.]
    • To get good, you have to practice all the time.
    • Anything that makes it easier for your users to get practice – any time, anywhere – will help them get their 10,000 hours (and get good) sooner.
  • Give your users patterns for success
    • In any pattern you give your users, make sure that there’s “the one thing” that they can take away as a lesson
    • You need to answer the question: “What’s the one thing you can do to be amazing?”
  • Give your users better gear
    • They’ll work better
    • “Spend the money!”
    • Give people a way to justify the better gear you’re offering them
  • Motivation is important
    • Treat motivation as a gift
    • Make a product that people will actually use
    • “Your treadmill is not in the corner gathering dust because you don’t use it, you don’t use it because it’s in the corner.”
    • “Make the right thing easy for people and the wrong thing hard.”
  • And now, some anti-patterns:
    • We focus on the tool and not the thing the users want to accomplish with the tool
    • “We treat people really well before they buy, and afterwards, we treat them poorly.”
      • This is also the reason people don’t want to upgrade
      • If we want to help people upgrade – which is what they’ll need to do if they want to go forward – we have to accept that it’s a loss and a hit to their self-esteem
    • We write FAQs as if our users they were intellectually curious and have a tablet PC handy
      • People hit the FAQs and help because they’re having a horrible experience
    • “Don’t let the ease-of-use police” step in an dumb something down
      • You don’t feel awesome when you’ve mastered something that a 3-year-old can master
    • Hiring a social media consultant is the wrong thing to do
      • They focus in the wrong direction
      • Social media consultant are focused on making your users love you, which is the wrong thing – nobody is awesome because they love you
      • They think the goal is to make users want to party with you
      • The true goal is to make your users want to party because of something you did that helped them become awesome. They should want to party because of you, but without you
      • You want to connect users with other users, not with your company
      • A much better use of social media is to find out:
        • What role we play in our users’ lives
        • What role our competitors play in our users’ lives
        • What the pain and pleasure points for our users are
      • By trying to be competitive and focusing on our competitors, we end up being uncompetitive
        • This leads to featurities
        • We end up building things that end up harming our users
        • The best thing we can do is to look at the bigger, cooler thing – the world in which our products and our competitors’ products exist, the problems that the products are trying solve, the things at which our users are trying to kick ass – and blog, tweet and use social media about that
    • Getting WOM (Word-of-Mouth) may be the social marketers’ holy grail, but the true goal is WOFO – Word of [Effing] Obvious.
      • If your users are so good, you get WOFO.

What It Means to Be a Leader

I haven’t made a new post for a long time – sorry for that! In fact I was quite busy and there were more important things in my life – we all have such periods. Recently my girlfriend dropped me a link to a short video explaining what it means to be a leader – in quite unusual way. I was really blown away by the simplicity and correctness (in my view) of the definition. It is definitely worth 10 minutes of your time!

Cute Short Movie By Pixar

Just found this amazing short movie by Pixar. Brilliant!

Haircut Showing Support To Linux :)

Last week I made a special haircut to show my support to Linux and Gentoo in particular. Isn’t it beautiful? ;)

Haircut showing Linux support

Haircut showing Linux support - side A

Haircut showing Linux support - side B

Haircut showing Linux support - side B

Coremoid – Simple CPU Usage Plasmoid For KDE4

Update: There is a nice replacement for coremoid plasmoid in KDE 4.3.x. It shows kernel and user space usage in different colors, shows swap usage, etc. I find it more useful than coremoid. You may want to try it instead of coremoid plasmoid.

I’ve been using Coremoid plasmoid since KDE 4 was available only in SVN and it provides everything I want. The plasmoid sits in the tray and displays processor usage on all cores (in case your processor has more than one core) plus the processor governor and frequency. It is useful to see whether your computer is doing something CPU intensive that you didn’t want it to do (for example there is a program hanging in memory and consuming your CPU).

The look & feel of Coremoid plasmoid

The look & feel of Coremoid plasmoid

It hasn’t been actively supported since last year and the sources from kde-look.org don’t compile with latest KDE 4.2.x stable. I have made few adjustments to the code to make it compile and decided to share it with you :)

Download coremoid-0.3.1-andrew.tar.bz2

Aptana Studio Optimization

I’ve been picking up a decent PHP & Python IDE for some period and decided to try Aptana Studio. I had Eclipse with PHPEclipse installed for some time but then dropped it because I thought it was too slow. Aptana Studio isn’t faster than Eclipse + PHPEclipse in any way but I liked it.

This time I decided to tune Aptana’s Java virtual machine to achieve top possible performance. To do that I edited the file AptanaStudio.ini usually located in “C:\Users\<YOUR_USERNAME\AppData\Local\Aptana Studio 1.2″ if you install it on Vista using default settings. You may just search for AptanaStudio.ini to find out where it is.

So here is the contents of my file. I will explain the meaning of each line I added or modified. The arguments added or modified are located after -vmargs (arguments to the virtual machine).

-name
Aptana
Studio
-vmargs
-Xmx384M
-Xms128M
-Xverify:none
-XX:+UseParallelGC
-XX:+AggressiveOpts
-XX:+UseFastAccessorMethods
-XX:CompileThreshold=100
-Djava.awt.headless=true
-Djava.awt.nativeDoubleBuffering=true

  • Xmx384M – maximum heap(memory) size Aptana can consume (384Mb). This value is set automatically by the installer based on the amount of memory installed on your computer. You may adjust it to give Java machine more memory to cache compiled code
  • Xms128M – the initial heap(memory) size. It is the minimum amount of memory Aptana will consume. Increasing this value will speed up start up a little
  • Xverify:none – skip the class verification stage during class loading . Using -Xverify:none disables Java class verification, which can provide a 10-15% improvement in startup time
  • XX:+UseParallelGC – use parallel (throughput) garbage collector. Can provide significant performance boost on modern computers with several cores or processors. Surpisingly, it shows good performance even on single core processors
  • XX:+AggressiveOpts – turns on point performance optimizations that are expected to be on by default in upcoming releases of Java machine.
  • XX:+UseFastAccessorMethods – turns on fast method entry code for accessor method. Improves performance.
  • XX:CompileThreshold=100 – this switch will make startup time slower, by Java machine to compile many more methods down to native code sooner than it otherwise would. The reported result is snappier performance once Aptana  is running, since more of the UI code will be compiled rather than interpreted. This value represents the number of times a method must be called before it will be compiled.
  • Djava.awt.headless=true – this line is present in the .ini file by default
  • Djava.awt.nativeDoubleBuffering=true – tells the UI to use hardware double buffering instead of drawing everything in software. Not sure it have any effect because of the switch above (headless=true) which tells Java there is no monitor or keyboard connected to the computer

The result of the modifications of AptanaStudio.ini is faster and more responsive Aptana. I also use the Port of Ruby Blue color theme for Aptana which looks very nice :) See the screenshot below:

Aptana Studio with color theme port of ruby

Aptana Studio with color theme "Port of Ruby Blue"

“No” to genkdesvn

As many of you already know the KDE team has released a stable version of KDE 4.2. I’ve been running KDE compiled from trunk (genkdesvn) with the latest features and bugs for a half year but now I feel tired of fighting with the bugs and since I don’t report them to KDE team anyway I decided to switch from genkdesvn to the stable 4.2. I just feel I don’t have time for this right now and I need a stable desktop.
Thanks to the KDE team for their wonderful piece of software!! I wish ATI drivers for linux were stable too..

Caveats About Restoring Linux Root Partition From TAR Archive

Recently I had to create a new partition on my laptop’s hdd to install OS X (I wanted to have a dual boot of Gentoo and OS X). I had no free space on the disk so the only way to create a new partition was to shrink the existing root partition with Gentoo. Since it was formatted as JFS and JFS doesn’t allow shrinking I had to back up all the data on the root partition, delete it, create a new (smaller) one and format it as JFS. So the steps were:

  1. Create a backup of the root partition with tar -cvpjf --sparse --one-file-system backup_of_root.tar.bz2 /
    Note
    : only the contents of the root partition will be archived since –one-file-system option is specified (no dev, proc, …) WARNING! If your filesystem is mounted with extended attributes support (see /etc/fstab) and you use programs utilizing this feature (such as SELinux) you shouldn’t use tar since it won’t store any extended attributes. Use sta, pax or cpio
  2. Boot with a live CD and delete the partition as well as create a new one with fdisk
  3. jfs_mkfs /dev/sdaN (where N is the partition number)
  4. Extract the backup with tar -xvpjf  backup_of_root.tar.bz2
  5. Reboot and … a kernel panic :)   On my system it was “Kernel panic – not syncing: Attempted to kill init!”

After a week of kernel debugging, initrd debugging and browsing of forums I have finally found out that init script is missing character files in /dev filesystem: /dev/console and /dev/null. Without these two your Gentoo installation (and some other distributions as well) just won’t boot without telling you why!

So all you need to do to make your restored system boot again are two commands:
mknod /dev/null c 3 1
mknod /dev/console c 5 1

Happy fixing! :)

Bad Crash Of Daniel Albrecht In Kitzbühel

Yesterday Daniel Albrecht landed badly just a hundred meters away of the finish gates in Kitzbühel, Austria on a downhill training course. A serious mistake and a crash that will likely take months to recover. Most likely he just didn’t expect a jump from such a steep track. I’m a fond of skiing and giant slalom/downhill so this topic worries me a lot. The video shows the price of the mistake at 138 km/h..