Ask / Submit

backup sms in android phone [answered]

asked 2017-12-10 01:10:15 +0300

Nick gravatar image

hello to all sailors. help me. I tried to follow the guide for backing up the already existing sms. but I can not save text messages in an android phone. I ask you for help. Being that now my jolla fist edition is abandoning me ... before losing all my data I would like to pass them on android. can you help me with this step? from jolla sms to android sms? Thank you very much. thank you.

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by nthn
close date 2018-02-02 18:25:51.545216

2 Answers

Sort by » oldest newest most voted

answered 2017-12-11 08:14:33 +0300

dreamer gravatar image

For SMS backup follow the instructions given in this link

1.First create empty script file in Jolla phone example: and copy below commands to this file


# A script to dump all text messages to stdout
# Usage:
#    sms-dump-xml
# (or whatever you choose the name the script)

# The database with the SMS messages

# The SQL query to count the messages
#    type      : Messages are of type 2
sql_count_query="SELECT COUNT(*) FROM Events WHERE type=2;"

# The SQL command to select which messages to retrieve
#    remoteUid : The contact's phone number
#    direction : The message direction, can be 1 (received) or 2 (sent)
#    startTime : When the message was sent (timestamp)
#    freeText  : The text of the actual message
#    isRead    : Whether the message is read (1) or not (0)
#    type      : Messages are of type 2
sql_list_query="SELECT remoteUid, direction, startTime, isRead, freeText FROM Events WHERE type=2;"

# Don't let root run this
if [ $UID -eq 0 ]; then
    echo "Do not run as root."
    exit 1

# Count the messages
nb_messages=`sqlite3 "$sql_database" "$sql_count_query"`

# Display the XML header
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'
echo '<?xml-stylesheet type="text/xsl" href="sms.xsl"?>'
echo "<smses count=\"$nb_messages\">"

# Get the message data from the phone's database
# Parse each line and print it, nice and pretty
sqlite3 "$sql_database" "$sql_list_query" | while read line; do

    # Check for the desired format...
    format=`echo $line | sed -e 's/.*|[12]|[0-9].*|.*/CORRECTFORMAT/'`

    if [ "$format" == "CORRECTFORMAT" ]; then
        # write sms if it is complete
        if [[ ${firstLine} == false ]]; then
        echo "  <sms protocol=\"0\" address=\"$contactno\" date=\"$timestamp\""\
             "type=\"$direction\" subject=\"null\"" "body=\"$message\" toa=\"null\""\
             "sc_toa=\"null\" service_center=\"null\" read=\"$read\" status=\"-1\""\
             "locked=\"0\" />"

        # Get the contact's phone number
        contactno=`echo $line | cut -d '|' -f 1`
        # Get the message direction
        direction=`echo $line | cut -d '|' -f 2`

        # Convert the Unix timestamp to a millisecond-based timestamp
        unixtime=`echo $line | cut -d '|' -f 3`

        # Get the read status
        read=`echo $line | cut -d '|' -f 4`

        # Get the actual text message
        message=`echo $line | cut -d '|' -f 5 | sed 's/&/\&amp;/g' | sed 's/\"/\&quot;/g'`
        # append the next line


echo "</smses>"

2.Using terminal change drive to the destination folder containing file.

3.In the terminal type ./ >SMS.xml

4.This will create SMS.xml file in the destination folder of

5.Now in the android phone download this app SMS Backup & Restore.

6.In the android phone copy the SMS.xml file to SMSBackupRestore folder

7.Now open SMS Backup & Restore app in the android phone and restore the SMS using this app.

edit flag offensive delete publish link more


Thanks a lot for the answer. as soon as I find the time after work, I try. can I bother you if I have problems? Thanks in advance. hello dreamer

p.s. I had tried that guide but I could not back up. now I try again. Thanks again.

Nick ( 2017-12-11 22:25:09 +0300 )edit

@Nick change the permission of script file before running the script file( need to log in as a root(develop-su) for changing the permission(chmod 755) of script file.But exit the develp-su before running the script file.Above script file worked for me for SMS backup..

dreamer ( 2017-12-14 16:42:08 +0300 )edit

It worked though i dont use Android SMS, can you describe the App and.provide a link to the SMS app you are referring to?

DarkTuring ( 2017-12-14 17:56:25 +0300 )edit

@dreamer Do you have a similar script to import SMS backup created in "SMS Backup & Restore" in Sailfish OS?

mcencora ( 2018-01-31 16:04:46 +0300 )edit

Worked really well. Thank you.

Tuokki ( 2018-05-04 00:12:17 +0300 )edit

answered 2017-12-13 23:03:40 +0300

Nick gravatar image

hi dreamer. i have a problem. image my jolla error

the terminal gives me an error. permission denied after doing: - cd / home / nemo / documents - chmod 755 - cat | col -b> - ./

I can not continue ... help me please. I attached the image of the error (it is in Italian)

thanks a lot.

edit flag offensive delete publish link more



@Nick Doing chmod +x before running the script will probably help you :)

ced117 ( 2017-12-14 00:41:44 +0300 )edit

Question tools



Asked: 2017-12-10 01:10:15 +0300

Seen: 804 times

Last updated: Feb 01 '18