Friday, August 27, 2010

Backup on Linux

One of the few things for I still have to switch to Windows is backup.
As I wrote before, for that job I have put up a small bat file that relies on robocopy to do the job.
Finally I came up with a similar shell script for Linux that does the same job using rsync.
Now the backup script on Linux reads the same list file as the backup script on Windows (my NTFS drives are mounted in Linux).
It looks like this

#!/bin/sh


TARGET=/media/SAMSUNG/BACKUP
SYNC='rsync -rptgovF --delete --delete-excluded'


# Backup Windows drives
LIST=/home/peter/Documents/Documents/Backup/backup.lst
cat $LIST | fromdos | sed s/\\\\/\\//g  | while read -r line 
do
echo BACKUP $line
case "$line" in
C:*) $SYNC "/media/Windows 7${line#C:}/" "$TARGET${line#C:}";;
D:*) $SYNC "/media/Data${line#D:}/" "$TARGET${line#D:}";;
esac
done


# Backup Linux drive
echo BACKUP /home/peter
$SYNC /home/peter/ "$TARGET/home/peter"


The F option tells rsync to look for file .rsync-filter in each directory. If it is present it specifies files to exclude from that directory.
In a typical UNIX way several commands are chained via pipes.
fromdos is used to convert the text file from Windows to UNIX format, i.e. strip CR chars as they would cause problems later on.
sed is used to replace all back slashes to forward slashes.
${line#C:} and {line#D:} macros produce the path without the drive.

UNIX shell scripting proved once again to be very powerful.

Monday, August 23, 2010

Sling

Have been checking Sling recently. Basically yet another Java web framework, but this one has a rather interesting approach - it is content oriented. It is based on OSGi, JCR, REST, server side scripting, etc. The recently popular principle convention over configuration is heavily used.
Found this brief intro to Sling.
Also this cheat sheet gives a condensed overview over the Sling way.

Although both projects Sling and Jackrabbit are hosted at Apache, they are led by a company called Day.
It is interesting that Roy T Fielding is a chief scientists at Day.

Sunday, August 15, 2010

Cyrillic in Wine

As windows is still much more popular than Linux there are some Windows applications that still do not have a Linux version. In these cases WineHQ comes to rescue. It allows installing and running Windows applications directly on Linux.
One such applications that I use is AceMoney Lite. But I encountered one problem - the application does not show properly text in Cyrillic like text in Bulgarian or Russian.
The solution that works for me is to set the LANG environment variable to Bulgarian.
After running the installation of a Windows application using Wine, it appears in Applications > Wine > Programs menu. So it can be launched just like an ordinary Linux application. So I opened the properties of AcemoneyLite launcher. The command there looked like this
env WINEPREFIX="/home/peter/.wine" wine "C:\Program Files\AceMoney\AceMoney.exe" 
I inserted LANG=bg_BG.UTF-8 before wine and now the cyrillic works just fine in AceMoney Lite.

I found the same trick works also for Picasa. The Linux version of Picasa actually bundles Wine and runs on it. So there prepend env LANG=bg_BG.UTF-8 to the command so it looks something like this
env LANG=bg_BG.UTF-8 /opt/google/picasa/3.0/bin/picasa

...

UPDATE 2 Feb 2012   
Recently this stopped working in Ubuntu 11.10.
After several attempts I found that if I use LC_ALL=bg_BG.UTF-8 instead of LANG=bg_BG.UTF-8, it works again.

Saturday, August 14, 2010

Ubuntu

Since Windows 7 beta started complaining that it expires I have been trying again Ubuntu (10.04 Lucid Lynx).
Although it has improved significantly still the user experience is not as smooth as in Windows.  For example such basic things as DVD playback and Flash do not work out of the box.

I will try to share my findings about Ubuntu.

For me one of the major new features in Windows Vista is the search box in the start menu. No need to navigate through menus to find some program or browse through directories to locate some document, just press the Win key and start typing the name. A similar thing exists in Linux - Deskbar-Applet. And its even more powerful and flexible. Deskbar supports many extensions (searches) which interpret the search string in different ways. For example it can do simple calculations, can search in Google, Wikipedia, dictionary and many other things.

This is the Linux way - initially hard to setup but afterwards it is very powerful.