A step by step tutorial to test Android backup and restore

A step by step tutorial to test Android backup and restore


  • Android 7.0+
  • Google Play is present on device

Prepare device

  1. Add your Google Account, e.g. shizhen.sg@gmail.com to your device.
  2. Select the Google Account shizhen.sg@gmail.com as backup account inside device backup settings. Usually, it is under Settings -> System -> Backup -> Account.
  3. Remember to turn on Back up to Google Drive. See below screenshotBackup Settings on Device

Turn on Android app allowBackup attribute

Set android:allowBackup="true" inside AndroidManifest.xml. See below screenshot:


Test flows

  1. Install BackupRestore.apk.
  2. Open the app and modify the two EditText fields, click on button SAVE. E.g.Screenshot.
  3. Verify that the shared preferance already saved correctly. E.g.Screenshot.
  4. Perfom a backup.Check availble transport
    $adb shell bmgr list transports
    * com.google.android.gms/.backup.BackupTransportService

    Run the backupnow command

    #On Android 7.0 or later
    $adb shell bmgr backupnow com.arophix.backup.restore

    You should see something like below:

    Running incremental backup for 1 requested packages.
    Package @pm@ with result: Success
    Package com.arophix.backup.restore with progress: 512/1024
    Package com.arophix.backup.restore with progress: 1536/1024
    Package com.arophix.backup.restore with progress: 2560/1024
    Package com.arophix.backup.restore with result: Success
    Backup finished with result: Success
  5. Perfom a restore.Clear the app storage first.


    Check the token name of the dataset to retore using below command

    $adb shell dumpsys backup | grep Current

    You should see something like below, the hex string after Current is the token name to use.

    Current transport clients: 0
    Current:   30ebe10fc40cee0a

    Restore date using below command

    $adb shell bmgr restore 30ebe10fc40cee0a  com.arophix.backup.restore

    You should see something like below

    Scheduling restore: Pixel 2
    restoreStarting: 1 packages
    onUpdate: 0 = com.arophix.backup.restore
    restoreFinished: 0
  6. Verify the data is restoredOpen the app and click on button REFRESH. You should see the two EditText fields are updated to the content restored from GoogleDrive.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s