Hi
I’ve created a Python script to allow importing text messages & call history from an Android phone into a SailfishOS 5.x phone:
Basic documentation is included, but so you can get some idea about it before downloading that zip file, here is a copy of the documentation I wrote for it’s first release:
ImportSmsAndCallLogs.py
This script allows you to copy both text message (SMS & RCS) & phone call history from an Android phone onto your Sailfish OS 5.x phone. Only text is copied, not images, animations or formatted text. And it’s quite likely that at least a few items (possibly more) will be missing, so make sure to keep a backup of your Android text messages & call history, in case you need to check something important later.
This script worked for me, and I have tried to be careful, but I can’t make any guarantees about other people’s phones, because I had to reverse-engineer both Android’s & Sailfish OS’s database structures (mostly using my own data). So I could have easily overlooked something small or big (most likely a situation that doesn’t occur in my Android data). For example, I have no contacts who I’ve only messaged using RCS, but in that case my script has no way to work out the phone number associated with the messages, so those messages won’t be transferred. (There is a database table that might provide that information, but it’s empty on my Android phone’s backup. If you want to trust me with a backup of your Android phone, then I can see whether it’s possible…)
Both text messages & phone call history are handled by the same Comm History database on Sailfish OS, which is why this script handles both. There is a risk my script might corrupt your Comm History database in some way, causing your Phone & Messages apps to crash or return scrambled data (and that in fact happened more than once while I was developing this script). I have done my best to provide a way to recover your Comm History database in that case, by storing a backup of the old database before any changes are made, so the next time you run the script you are given the option to restore it. But just in case that doesn’t work for some reason, I also strongly recommend making a backup of your whole phone first.
No ‘AI’ was used at any point during research, development, testing, debugging, etc of this script.
Legal notice
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Requirements
-
A phone running Sailfish OS 5.x . Older OS versions might work, but it appears the database structure changed drastically at some point in the past. (My script should detect if something isn’t right, but it’s better to not risk it.)
-
You will need to enable Developer mode on your SfOS phone, so that you can run this script from the terminal. That’s not difficult, but you need a passing familiarity with the command line.
-
Some way to transfer a backup file from your Android phone to your SfOS phone. (Most people will probably use a USB cable to transfer the file from your Android phone to your computer, and then from your computer to your SfOS phone. But a MicroSD card would be a fine alternative.)
-
A way to unzip a file (may be simpler to do on your Android phone or your computer).
Usage
First you need to install Rerware’s My Backup app on your Android phone. I’ve only tested their paid My Backup Pro app:
https://play.google.com/store/apps/details?id=com.rerware.android.MyBackupPro
It’s possible their free My Backup app will work, but this is untested:
https://play.google.com/store/apps/details?id=com.rerware.android.MyBackup
More information about My Backup here, and an alternative way to download the app (although I don’t know if the downloadable APK on their website is up-to-date):
https://www.rerware.com/Mybackup.aspx
https://www.rerware.com/Android-Backup/
Use the My Backup app to create a Data backup, by going to New Backup > Data > Local. I backed-up everything (Select All), but in principle you should only need to tick “Call Log”, “SMS” & “MMS”. That should create a backup file called something like “Data_2026_09_12.zip” inside the folders “rerware/MyBackup/AllBackups” at your backup destination.
You need to unzip that backup file, and copy a file called “000000000000000.mbp” (or something like that) to your Sailfish OS phone, along with the “ImportSmsAndCallLogs.py” script I’ve provided.
Do NOT go to the next step until it’s a time of day/night when you are not expecting any phone calls or messages. That’s because if anything goes wrong, you will need to restore the database from a backup taken by my script, and you will loose a record of any new calls & messages that occur after my script was first run.
Just in case, make a backup of your whole SfOS phone, using Settings > Backup > Back up now - you’ll need a memory card in the phone. This might take some time if you have a large amount of videos or pictures on the phone’s internal memory.
Open the Terminal app on your SfOS phone, “cd” to the folder containing your backup file & my script, and then run the script:
./ImportSmsAndCallLogs.py
If that doesn’t work (because it’s missing the executable permission), then this should work instead:
python3 ImportSmsAndCallLogs.py
It will now say:
Not running as a privileged user. Press return to raise privileges using 'devel-su -p'...
Press return, and then enter your developer password. (Or if you don’t trust entering your password into my script, then instead run it using “devel-su -p” yourself.)
It will check the database structure looks correct, and report an error if it doesn’t. If it complains about not being able to open the MyBackup database “000000000000000.mbp”, the filename may be slightly different, in which case you will need to run the script again, this time passing the file as it’s first parameter, like so:
./ImportSmsAndCallLogs.py 000000000000000.mbp
If all is well, it will backup your Comm History database, and then ask you three questions in succession:
- Import call history from MyBackup? [y/N]
- Import SMS messages from MyBackup? [y/N]
- Import RCS messages from MyBackup? [y/N]
If you press return (or enter anything other than a “Y” followed by return), then that importing step will be skipped. And if any errors occur, it should undo the changes it made to the Comm History database.
After each step it will report how many entries were copied, and an estimate of the number of messages it was unable to copy. PLEASE let me know if you get any error messages!
If you run the script again, do NOT import the same thing twice, or you will end-up with duplicate entries!
Once you’ve finished, make sure to thoroughly check the contents of both the Messages & Phone apps. Make sure that everything is present & that the apps don’t crash or lag unexpectedly.
If you even slightly suspect there may have been a problem, please restore the Comm History database immediately from it’s automatic backup, by running the script again. This time it will ask if you want to restore the database from the oldest backup. You then need to restart (or power off & on) your SfOS phone ASAP, so the that it stops using the bad database & starts using the restored one. Beware that you will loose a record of any new calls & messages that have occurred since my script was first run (and made it’s first backup).
Please let me know about any problems you had with my script, along with as much details as possible (about your SfOS phone & the problems you had). I may ask if you would be willing to provide me with a copy of the “.ORIG” database files found in the “.local/share/commhistory” folder, but you only need to do that if you trust me with a copy of your text messages & call history.
Contacting me
It’s probably best to reply to me on the Sailfish OS Forum thread where you downloaded this script from (my username is “chr1s”). Just to be clear, this is the SfOS forum I am referring to:
https://forum.sailfishos.org/
You could also email me using the email address given on this web page:
As stated earlier, this script is free software, and is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY - and potentially without any support. Please beware that I might be busy & so very slow to respond, or I might not respond at all. The source code is provided, so you are free to find & fix bugs yourself (within the terms of the GPL). If something went badly wrong, then although I may try to help, you are ultimately responsible for resolving any problems yourself.