Importing contacts the hard way
Three days ago, I got my Nokia N9 and everything was fine.
One day later I flashed PR1.2 onto it. This broke Contact synchronization via Exchange. No matter what I tried, I couldn’t get it to work.
The synchronization not working is one thing, but not having the contacts on the phone at all is pretty bad, so I needed to find a way to bring them on there.
The N9 doesn’t support importing contacts from any files. The next best thing that came to my mind, were QrCodes.
Easy-peasy, just open up Google contacts, point the phone camera to the QrCodes of one contact after another and save it. But wait! Google Contacts doesn’t show any QrCodes. So I had to generate them myself. Of course I could upload the exported file with all contacts to a website and get back the Codes, but that’d mean that I’d transfer all my contact data to some strange website - not an option either.
The Linux program qrencode can convert contact data to a QrCode. That’s easy enough. Just use:
qrencode -o name.png “`cat name.vcf`”
Toying around, I found that Vcard was the only format supported by both Google Contacts export and the N9 Qr Code program.
So, the last problem I had, was that I’d have to download every contact’s vcard file. That’s a lot of work.
I ended up, exporting all the contacts at once and writing a Python program to separate the data into files for each contact:
(It’s uggly code, I’m not using Python that often…)
from vobject import readComponents
file = open(‘contacts.vcf’)
io = StringIO.StringIO(file.read())
string = io.getvalue()
for vcard in readComponents(string):
filename = vcard.fn.value+”.vcf”
filename = filename.replace(” “, “.”)
filename = filename.lower()
out = open(filename, ‘w’)
v = str(vcard.serialize())
Afterwards, I used a (very small) Shellscript to generate the png files:
for line in *.vcf;
qrencode -o $line.png “`cat $line`”
(You can use my code under the WTF Public License 2.0 http://sam.zoy.org/wtfpl/COPYING)
My new backup
When Sbackup failed to restore my /home-directory last weekend I was very frustrated!
Googeling for the error I found that SimpleBackup errors are not too rare.
One error once in a stable software really would not bug me, but several critical ones in a backup software are a total nogo.
So I was looking around for a new backup solution. I ended up having to make a decision between Deja-Dup and PyBackPack. I went for Deja-Dup because of the GnuPG encryption it natively supports.
I’v written a backup-script that will mount a directory on my NFS server on the local machine and do the backup to that (I don’t mount it by default, because an rm -rf /* would then also destroy the data on the drive).
So after configuring Deja-Dup I just had to add the line to call it to the script. Unfortunately it always asked for the password. I also found out that Deja-Dup only does Incremental backups. So I wrote these few lines:
if [ ! -d “$p” ]
#no last month directory found, creating it now!
#now moving all the backupfiles to last months directory
mv duplicity-* $p
It checks if a folder with the name of the last month exists. If not it creates one and moves all the backup files from base directory into that new one.
Whe Duplicity then runs the next times it finds the empty folder and thinks there was no full-backup yet. It will then do a new one ;)
Just when I was done, a friend pointed out to me, that I could simply use duplicity, for which Deja-Dup only is a front. I then changed the script.
Duplicity has the great advantage that it is capable of doing full-backup every so time and that I can include the GnuPG pass-phrase in the script :)
date » /var/log/backupscript.log
echo “#====#” » /var/log/backupscript.log
echo “starting script” » /var/log/backupscript.log
mount -t nfs 192.168.0.102:/niklaus /var/backup/niklaus && i=1;
if [ $i -eq 1 ]then
echo “drives succesfully mounted” » /var/log/backupscript.log;
echo “start backing up user-data” » /var/log/backupscript.log;
duplicity —full-if-older-than 2W —exclude-globbing-filelist /home/niklaus/Programme/exclude —archive-dir=/home/niklaus/.cache/duplicity —volsize=256 —verbosity=4 /home/niklaus file:///var/backup/niklaus/.backup/duplicity » /var/log/backupscript.log;
echo “unmounting drives” » /var/log/backupscript.log;
echo “END RUN” » /var/log/backupscript.log;
echo “#====# ” » /var/log/backupscript.log;
echo “drive could not be mounted!” » /var/log/bakupscript.log;