Creating & Restoring a backup of an Android app via ADB

Creating a backup via ADB (Android Debug Bridge) for an Android app can become crucial when the app’s native backup feature is unreliable or disabled.

Exactly this is the case for my beloved “Indoor Cycling Workout” app, as its integrated backup function is malfunctioning.

By creating a manual backup through ADB, I can proactively safeguard my fitness journey, mitigating the risk of data loss due to app glitches, hardware issues, or unforeseen circumstances.

Prerequisites

  1. Enabling Developer options:
    Open the “Settings” app, find the “Build number“, usually under “About phone” and tap the “Build number” repeatedly quickly until the message “You are now a developer!” appears.
Android Developer Options
Toggle the USB debugging switch on.
  1. Enabling USB debugging:
    After enabling Developer Options, go back to the main “Settings” menu, scroll down to “System“, where a new menu item called “Developer options” should be listed.
    Tap “Developer options” to enter the menu, scroll down in the Developer Options menu to find “USB debugging” and turn it on.
  1. Installing ADB:
    Make sure ADB is installed on your computer. You can download a simple and lightweight version for Windows, which is called “Minimal ADB and Fastboot“, from XDA.
  1. Launch ADB:
    After installing “Minimal ADB and Fastboot“, connect your phone with your computer, change the “USB settings” to “File transfer” and launch “Minimal ADB and Fastboot“.

Creating a backup

  1. Create a backup of the app:
    To back up a specific app, you need to know its package name. You can find this information by searching online or with the following ADB command to list all installed apps: pm list packages

    Run the following command to create a backup:
    adb -d backup -f D:\backup.ab -apk net.pierrox.indoorcyclingworkout

    adb : The ADB command-line tool is used to communicate with an Android device.
    -d : The command should be performed on the connected hardware device.
    backup : This is the ADB backup command.
    -f D:\backup.ab : Specifies the file path and name for the backup file.
    -apk : Indicates that the backup will not only include the app’s data but also the installation file.
    net.pierrox.indoorcyclingworkout : The package name of the Android application.
ADB Backup Command
ADB Android app backup command.
  1. Unlock your device and confirm the backup:
    After running the command, you may be prompted to unlock your device and confirm the backup. Follow the on-screen instructions on your device and set a password to encrypt the backup if needed.
Android Backup Prompt
Android full backup prompt.
  1. Verify the backup file:
    Once the backup process is complete, you should see a notification on your Android device “Backup finished” and a file named “backup.ab” should be created under the specified path.

Restoring a backup

  1. Restore the app backup:
    Use the following command to restore a previous created backup:
    adb -d restore D:\backup.ab

    adb : The ADB command-line tool is used to communicate with an Android device.
    -d : The command should be performed on the connected hardware device.
    restore : This is the ADB restore command.
    D:\backup.ab : This is the path to the backup file.
ADB Restore Command
ADB backup restore command.
  1. Unlock your device and confirm the restore:
    Your device will prompt you to confirm the restore process. Follow the on-screen instructions and enter the password to decrypt the backup if previously set.
Android Restore Prompt
Android full restore prompt.
  1. Wait for the restore to complete:
    The restore process may take some time. Once it’s finished, you should see a message on your Android device “Restore ended” indicating that the restore was successful.
asterix Written by:

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *