sailfishos:projects:sailfish_contacts_rescue

Intro

After Upgrading my mobile from SailfishOS 3.3.??? to 4.1.??? it figured out, that I've missed a backup with the OS tools. I've had only a backup of the filesystem. Restoring most of the relevant information was simple. So it was no problem to get my Phonecalls, Messages and also Notes back. Only two things didn't work. Contacts and Calendar. Allthough I can ignore my Calendar for the moment, also my contacts went away due to the fact, that there was a DB Schema change.

Luckily it was possible to start an emulator with OS 3.2.??? and restore the contacts within that emulator *but*, all tryes to restore the data with Backuptools on that emulator or CalDav syncing or vcardconverter on OS level failed. For whatever reason it was not possible to restore that data.

Solution

My Solution here is to restore the data with a python script, exporting it from the Sqlite database to .vcf (vCard File).

This only works for DB Structures of SailfishOS and was especially tested with DBs of OS version 3.2.X and 3.3.X

Version 0.7 is the latest one.

functionimplemented
Full Name
First Name
Last Name
voice number
fax number
sms number
e-mail addresses
Organization name
Organization parameters
picture / foto
address
birthday
URL
Notes

Install following Python Modules from PyPi

  • vObject
  • sqlite3
  • uuid
Help
$ ./ContactRestore.py --help
usage: ContactRestore.py [-h] --db DB --output OUTPUT [--outsinglefile OUTSINGLEFILE] [--avatars AVATARS] [--debug]
                         [--version]

Restore SailfishOS 3 Contacts

optional arguments:
  -h, --help            show this help message and exit
  --db DB, -d DB        Sqlite3 Database file usually /home/{nemo,defaultuser}/.local/share/system/Contacts/qtcontacts-
                        sqlite/contacts.db
  --output OUTPUT, -o OUTPUT
                        Output directory for vcf files.'
  --outsinglefile OUTSINGLEFILE, -f OUTSINGLEFILE
                        If specefied, a file with that name is created under specified path, contianing all VCard
                        entrie. E.G. your address book
  --avatars AVATARS, -a AVATARS
                        Avatar directory. If present otherwise we skip this block of avatars, means, no avatars at all
  --debug               debugging output to identify problems
  --version             show program's version number and exit

This script was written to restore SailfishOS 3 contacts as VCF files. To see additional information, visit:
https://wiki.siningsoft.de/doku.php?id=sailfishos:projects:sailfish_contacts_rescue
Execution
$ ./ContactRestore.py -d Testdata/contacts_with-Phone-Mobile-Fax-Pager-Assistent-Addresses.db -o Testdata/Output/
exporting SiSo Emulator to file Testdata/Output//SiSo_Emulator.vcf
exporting TestUserFirstName TestUserLastName to file Testdata/Output//TestUserFirstName_TestUserLastName.vcf
exporting 2nd Test *FN* User *LN* to file Testdata/Output//2nd_Test_*FN*_User_*LN*.vcf
exporting Phone Test to file Testdata/Output//Phone_Test.vcf
exporting Ludowig Adressuser to file Testdata/Output//Ludowig_Adressuser.vcf

Database

The database is missing a table with subTypes to identify entries in Addresses. To have a reference, here is a list of Types

subTypevCard/vobject parameterSailfishOS Contact label
NullpersonalPersonal Address
0 parcel
1cellCell Phone
2faxFax
3pagerPager
6videoVideo
10??Assistent

The Phonenumbers are listed in table PhoneNumbers with details from table Details. Most interesting here is the type of number. Which is stored in table PhoneNumbers column subTypes.

Here is an example:

detailIdcontactIdphoneNumbersubTypesnormalizedNumberdetailIdcontactIddetaildetailUrilinkedDetailUriscontextsaccessConstraintsprovenancemodifiablenonexportable
10301719994445119994445103PhoneNumberNULLNULLHome0NULLNULLNULL
113040111222334NULL11222334113PhoneNumberNULLNULLHome0NULLNULLNULL
12301720004443120004443123PhoneNumberNULLNULLWork0NULLNULLNULL
133040111222333NULL11222333133PhoneNumberNULLNULLWork0NULLNULLNULL
143040111222335211222335143PhoneNumberNULLNULLWork0NULLNULLNULL

The database is missing a table with subTypes to identify entries in PhoneNumbers for example. To have a reference, here is a list of Types

subTypevCard/vobject parameterSailfishOS Contact label
NullvoiceVoice Phone
1cellCell Phone
2faxFax
3pagerPager
6videoVideo
10??Assistent

Definition from RFC:

 +-----------+-------------------------------------------------------+
 | Value     | Description                                           |
 +-----------+-------------------------------------------------------+
 | text      | Indicates that the telephone number supports text     |
 |           | messages (SMS).                                       |
 | voice     | Indicates a voice telephone number.                   |
 | fax       | Indicates a facsimile telephone number.               |
 | cell      | Indicates a cellular or mobile telephone number.      |
 | video     | Indicates a video conferencing telephone number.      |
 | pager     | Indicates a paging device telephone number.           |
 | textphone | Indicates a telecommunication device for people with  |
 |           | hearing or speech difficulties.                       |
 +-----------+-------------------------------------------------------+
    The default type is "voice".

VCARD

Allthough it wasn't specified by python vobject lets assume we've to use VCard specification by RFC6350.

external Links

ToDo

  1. fotos
  2. birthday
  3. missing parameters for names
  4. URL with parameters

source

The sourcecode is located under svn://svn.siningsoft.de/Sailfish_Contacts_Restore. A free read access via svn will follow. If you're interested in submitting code as part of the development, a read/write access could be requested via sailfish@siningsoft.de

× iphelper toolbox

you see this when javscript or css is not working correct

Untested
IP Address:
First usable:
Subnet:
Last usable:
CIDR:
Amount of usable:
Network address:
Reverse address:
Broadcast address:

  • sailfishos/projects/sailfish_contacts_rescue.txt
  • Zuletzt geändert: 2021/10/15 10:32
  • von admin