Copy contacts.db from old device to new device results in empty people app

isn’t it possible to copy the contacts.db from an old device to a new one or in another location as a backup? i copied contacts.db and the other two files in that folder to my computer and when in overwrote the database on a flashed saifish device the peoples app doesn’t load the contacts. unfortunately i don’t have access to the old device. has anyone got an idea how to get out the contacts from contacts.db?

There are some entries related to sim cards which will probably need to be corrected (CollectionsMetaData - ModemIdentifier), then there are entries about avatars from ~/.local… You could try to import the data into a fresh contacts.db that has the right modemidentifiers, maybe it would work

thanks for your suggestion. unfortunately it didn’t work. what’s strange, it somehow seems that the database is empty when i open it with sqlite or conversion to csv on a conversion website shows no entries in the db. could it be that it is encrypted since jolla introduced encryption?

  1. What was the SFOS version of the old device? 3.4 or a 4.
  2. Did the files go to: .local/share/system/privileged/Contacts/qtcontacts-sqlite
  3. Did you set the permissions to owner defaultuser and group privileged ?

As throwaway said there may be differences in meta data, but the schema of the db may also have changed.

You could, with the files in those directories try:

devel-su -p vcardconverter --export contacts.vcf

thanks for your reply. it went from sfos 4 to sfos 4. privileged doesn’t exist in system it’s directly Contacts and i didn’t set the permissions, i will try that.

maybe i just copied as regular user and it didn’t copy the privileged folder…

Ok, you have to copy with devel-su. It’s a bit strange, but that is directory the defaultuser (or nemo) can’t write to without root.

Just do:
devel-su chown defaultuser:priviledged .local/share/system/privileged/Contacts/qtcontacts-sqlite/*
for those files.

yes, thanks for your help. i wrote as root, but it seems i couldn’t copy the privileged folder as defaultuser and since i flashed the old device too, i guess the contacts are lost

at least the messages got copied. so i guess the contacts could be recreated, although quite time consumingly

did you try

devel-su find /home/defaultuser -name contacts.db
?

No i didn’t. I found locate to be more efficient for me. Very strange i explicitely copied the contacts.db with contacts back to a newly flashed phone and the contacts didn’t show up. Then i set the owner and now the people app is blank. Very veird. I will try to convert the db somehow

Did you set the group too as poetaster wrote above?
Did you copied all files in that dir?
There is also a workaround. You can import all.vcf file from backup.

Yes the group too. Unfortunately i haven’t got a backup in that sense i just copied the content of /home/defaultuser onto an sdcard

I wonder if all the files are in the correct place? I have two when I search and, frankly don’t know why there are two:

[defaultuser@Phone22 ~]$ devel-su find /home/defaultuser -name contacts.db
Password: 
/home/defaultuser/.local/share/system/privileged/Contacts/qtcontacts-sqlite/contacts.db
/home/defaultuser/.local/share/system/Contacts/qtcontacts-sqlite/contacts.db

BUT opening them with sqlite3 indicates that it’s the first one that has data.

Try (zypper in sqlite first):

sqlite3 /home/defaultuser/.local/share/system/privileged/Contacts/qtcontacts-sqlite/contacts.db
sqlite> select count(*) from contacts;
612

Here you see 612 contacts. Who are all these people!

Take care of also copying and chowing contacts.db-shm and contacts.db-wal as, iirc, they are also part of the db.

The -wal file is, the -shm file isn’t.

Ideally though, neither should even exist at the point of taking a backup (because their presence means there are clients connected to the database).

This is what I use for backing up SQLITE databases:

  /usr/bin/printf "vacuum into '%s';" /path/to/backup/database.db | /usr/bin/sqlite3 -readonly /path/to/live/database.db

Can be used while the db is in use, and can save some space too.

2 Likes