As I wrote before, a few months ago my N900 (touchscreen) died and without a working touchscreen it proved to be impossible to operate it. Therefore I ordered a new one which could, but did not fix my phone.

In order to recover my text messages I wrote a simple Python script which reads the el-v1.db file in comm_and_cal.zip:/home/user/.rtcom-eventlogger/backup.tgz (which is an SQLite 3 database) and writes the messages to a CVS file (which are better handled by other phones).

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import sqlite3
import os.path
import csv
from datetime import datetime

if len(sys.argv) != 3:
  print ""
  print "Usage:"
  print "%s [path to el-v1.db] [path to csv file]" % sys.argv[0]
  print ""

dbFileName  = sys.argv[1].strip()
csvFileName = sys.argv[2].strip()

if not os.path.exists(dbFileName):
  print ""
  print "Error:"
  print "Could not open '%s'" % dbFileName
  print ""

with sqlite3.connect(dbFileName) as connection, open(csvFileName, 'wb') as csvFd:
  cursor = connection.cursor()
  writer = csv.writer(csvFd, delimiter = '\t', quotechar = '"', quoting = csv.QUOTE_ALL)

  sql = "SELECT start_time, remote_uid, free_text FROM Events WHERE event_type_id = 7"
  for record in cursor.execute(sql):
    startTime, phoneNumber, textMessage = record
    startDateTime = datetime.fromtimestamp(startTime).strftime('%Y-%m-%d %H:%M:%S');
    phoneNumber   = phoneNumber.encode('utf-8')
    textMessage   = textMessage.encode('utf-8')

    writer.writerow([startTime, startDateTime, phoneNumber, textMessage])





A few months ago my N900 (touchscreen) died. Without a working touchscreen it proved to be impossible to operate it. Although I could have logged in via SSH unfortunately my WIFI and 3G were of 🙁 So there was no possibly to create an export of all my data. Fortunately I had a backup. The only problem was that the backup was just a set of zip files:

# ll
totaal 4,0M
-rw-r--r-- 1 lorem ipsum 1,1K sep 25  2011 applications.zip
-rw-r--r-- 1 lorem ipsum  678 sep 25  2011 backup.metadata
-rw-r--r-- 1 lorem ipsum 233K sep 25  2011 bookmarks.zip
-rw-r--r-- 1 lorem ipsum 2,2M sep 25  2011 comm_and_cal.zip
-rw-r--r-- 1 lorem ipsum 1,6M sep 25  2011 settings.zip

containing “raw” dumps of directories. Not particularly useful for transferring to a new phone…

After some searching I found a file called addressbook.db (in comm_and_cal.zip:/home/user/.osso-abook-backup/db/) which should contain my contacts (vcard data). I read that addressbook.db was a Berkeley DB (BDB) database file. Because I was learning Python I wrote a simple script to extract the vcard data from the database and write it as separate vcards (which are easy to import on other devices) to a folder.

I hope it useful for someone else and please comment my python skills 🙂

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import vobject
from bsddb3 import db

if len(sys.argv) != 2:
  print ""
  print "Usage:"
  print "%s [path to addressbook.db]" % sys.argv[0]
  print ""

fileName = sys.argv[1].strip()

addressBookDb = db.DB()
  # Try to open db file
  addressBookDb.open(fileName, None, db.DB_HASH, db.DB_DIRTY_READ)

  cursor = addressBookDb.cursor()
  record = cursor.first()

  # Fill a list with vcard strings from db 
  vCards = []
  while record:

    # Get vcard string and correct line endings
    vCardString = record[1].replace('\x00', '\r\n')

    record = cursor.next()

  # Write vcard strings
  for vCard in vCards:

    parsedVCard = vobject.readOne(vCard)
    # Not all entries have a n(ame) attribute
    if hasattr(parsedVCard, 'n'):
      vCardName = str(parsedVCard.n.value).strip()
      # Open vcard for writing
      with open('vcards/%s.vcf' % vCardName, 'w') as fd:

except db.DBNoSuchFileError:
  print ""
  print "Error:"
  print "Could not open '%s'" % fileName
  print ""



Recently I needed to “rename” a user (mischa_new -> mischa-new). Personally I find changing only the name a bit ugly and confusing. So this is how I addressed it:

Change username

usermod -l mischa-new mischa_new;

Change home directory (move)

usermod -d /home/mischa-new -m mischa-new;

Change group name

groupmod -n mischa-new mischa_new;

Personally I find Gnome’s `Recent documents` feature quit annoying. In earlier versions I always disabled it like this. Unfortunately that didn’t work anymore… Apparently .recently-used.xbel has moved to a new location (thanks ade). It is now in ~/.local/share/recently-used.xbel. So this should do the trick:

rm ~/.local/share/recently-used.xbel -Rf;
mkdir ~/.local/share/recently-used.xbel -p;