Android/adb

From Gentoo Wiki
Jump to: navigation, search

With a non rooted device, the only things you can backup locally is what the couple device/android will let you do. That is pretty much the same files you can copy with the already mentioned software. With the Android 4.x devices, a nice solution to make such a partial backup is the so-called "adb backup".

adb stands for Android Debug Bridge[1], and it is a part of the Android Software Development Kit (SDK)[2]. It can be installed with dev-util/android-sdk-update-manager

root #emerge --ask android-sdk-update-manager

Install dev-util/android-tools:

root #emerge --ask dev-util/android-tools

When it is done, you may have to logout and login in order to backup the files with

user $adb backup [-f <file>] [-apk|-noapk] [-shared|-noshared] [-all] [-system|nosystem] [<packages...>]

where:

  • -f : the path of the *.ab file that will be saved on your computer. This file is a compressed file that contains an archive of the data/apks from your device.
  • -apk|-noapk : indicates if the *.apk files should be backed up (default is -noapk)
  • -shared|-noshared: enable/disable backup of the device's shared storage / SD card contents (default is -noshared)
  • -all : indicates that you want the entire system backed up. you can use the packages filter to just backup specific packages, or use -all for a full system backup.
  • -system|-nosystem: indicates if all the system applications and data are included when backing up. (default is -system)
  • <packages> : this is where you can list specific packages to backup. Use these if you want to back up only specific applications. If using -all, you do not need to specify packages.

To backup the phone into ~/HTC_backup :

user $cd ~
user $mkdir HTC_backup
user $adb devices

will start the daemon and show you the devices on the USB.

user $adb backup -apk -shared -all -system -f ~/HTC_backup/backup<date_of_the_day>.ab

will backup every thing the device will let you to backup.

user $adb restore ~/HTC_backup/backup<date_of_the_day>.ab

will restore the backup into the device.

To stop the daemon:

user $adb kill-server

References