backup full sms/mms contents via adb

后端 未结 3 1354
北恋
北恋 2020-12-23 02:34

I\'ve been attempting to use adb to pull the sms/mms inbox in its entirety from the device but am having some trouble. The phone is rooted and I\'ve tried the following comm

相关标签:
3条回答
  • 2020-12-23 02:45

    You have to give ADB root privalages before you pull that database

    adb root
    
    adb pull /data/data/com.android.providers.telephony/databases/mmssms.db ./
    
    0 讨论(0)
  • 2020-12-23 03:04

    Thanks to @Bonlenfum's answer I was able to come up with a reusable script for copying any file/directory on a rooted device to a Windows path (local or UNC).


    Edit: Fixed bug with paths containing spaces.


    Save the following as: adbSuPull.bat

    @echo off
    
    SetLocal
    set RemotePath=%~1
    set LocalPath=%~f2
    
    if [%1] == [] goto Usage
    if "%~1" == "/?" goto Usage
    if not [%3] == [] goto Usage
    
    :: Replace " " with "\ " (escape spaces)
    set RemotePath=%RemotePath: =\ %
    
    set TimeStamp=%date:~-4,4%-%date:~-10,2%-%date:~-7,2%_%time:~-11,2%-%time:~-8,2%-%time:~-5,2%
    
    :: Replace spaces with zeros
    set TimeStamp=%TimeStamp: =0%
    
    if "%LocalPath%" == "" set LocalPath=adbSuPull_%UserName%_%TimeStamp%
    set SdCardPath=/mnt/sdcard
    set TempPath=%SdCardPath%/adbSuPull_temp_%TimeStamp%/
    
    echo.
    echo Copying to temp location "%TempPath%"
    echo.
    adb shell "su -c 'mkdir -p %TempPath%; cp -RLv %RemotePath% %TempPath%'"
    
    echo.
    echo Copying to destination "%LocalPath%"
    echo.
    adb pull "%TempPath%" "%LocalPath%"
    if ErrorLevel 0 goto Cleanup
    
    :Error
    echo.
    echo Operation failed. Is USB Storage in use?
    echo.
    pause
    call Cleanup
    exit /b 1
    
    :Cleanup
    echo.
    echo Removing temp location "%TempPath%"
    echo.
    adb shell "rm -Rf '%TempPath%'"
    exit /b ErrorLevel
    
    :Usage
    echo.
    echo.adbSuPull ^<RemotePath^> [^<LocalPath^>]
    echo.
    echo Copies files/directories from a rooted Android device to a Windows path.
    echo Author: Ben Lemmond benlemmond@codeglue.org
    echo.
    echo.  RemotePath (required)  Specifies the path to the file or directory on
    echo.                         the rooted Android device.
    echo.
    echo.  LocalPath (optional)   Specifies the destination path. This can be a
    echo.                         Windows local path (C:\folder) or a UNC path
    echo.                         (\\server\share).
    echo.                         Defaults to adbSuPull_%%UserName%%_%%TimeStamp%%
    echo.                         in the current working directory.
    exit /b 1
    

    Usage:

    adbSuPull <RemotePath> [<LocalPath>]
    
    Copies files/directories from a rooted Android device to a Windows path.
    Author: Ben Lemmond benlemmond@codeglue.org
    
      RemotePath (required)  Specifies the path to the file or directory on
                             the rooted Android device.
    
      LocalPath (optional)   Specifies the destination path. This can be a
                             Windows local path (C:\folder) or a UNC path
                             (\\server\share).
                             Defaults to adbSuPull_%UserName%_%TimeStamp%
                             in the current working directory.
    
    0 讨论(0)
  • 2020-12-23 03:05

    One way to fetch contents of the /data directory is to first copy the sqlite db to somewhere that is accessible, and then using adb pull to copy from there to the host.

    For example, the following commands use the android bridge to grab the sms data (assuming it is contained in /data/data/com.android.providers.telephony/databases/mmssms.db):

    adb shell
    $ mkdir /mnt/sdcard/tmp
    # su
    # cat /data/data/com.android.providers.telephony/databases/mmssms.db > /mnt/sdcard/tmp/mmssms.db
    # exit
    $ exit
    adb pull /mnt/sdcard/tmp/mmssms.db .
    

    Now you have the mms/sms database on your host machine, probe to find most popular recipient, for example:

    sqlite3 -header mmssms.db 'select address from sms' | sort -n | uniq -c | sort -n
    

    Finally, tidy up the temp area:

    adb shell
    $ rm /mnt/sdcard/tmp/mmssms.db
    $ rmdir /mnt/sdcard/tmp
    $ exit
    
    0 讨论(0)
提交回复
热议问题