How To Backup an Android Phone to a Linux PC

These are my notes about doing the backup of a Samsung S4 GT-I9515 smartphone running Android 5.0.1 to a Fedora Linux 23 Workstation Edition system.

Install the ADB tools

On the Linux system, install the ADB tools (Android Debug Bridge):

root@localhost ~]# dnf install android-tools
[root@localhost ~]# 

Enable Developer mode on the smartphone

Connect the phone to the Linux system.

It is needed to enable the developer mode on the smartphone. This can be done by going to "Settings" => "More" => "About device" => tap on "Build number" until you get a message saying that the developer mode was enabled.

The new entry "Settings" => "More" => "Developer options" will appear. You need to check the "USB debugging" box.

The smartphone will ask if you want to connect to the PC, you need to answer "yes".

Do the backup

On the Linux system can run the command "adb" without arguments to see all the possible options.

[root@localhost ~]# adb
Android Debug Bridge version 1.0.32

 -s           - directs command to the device or emulator with the given
                                 serial number or qualifier. Overrides ANDROID_SERIAL
                                 environment variable.
 devices [-l]                  - list all connected devices
                                 ('-l' will also list device qualifiers)
device commands:
  adb backup [-f ] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] []
                               - write an archive of the device's data to .
                                 If no -f option is supplied then the data is written
                                 to "backup.ab" in the current directory.
                                 (-apk|-noapk enable/disable backup of the .apks themselves
                                    in the archive; the default is noapk.)
                                 (-obb|-noobb enable/disable backup of any installed apk expansion
                                    (aka .obb) files associated with each application; the default
                                    is noobb.)
                                 (-shared|-noshared enable/disable backup of the device's
                                    shared storage / SD card contents; the default is noshared.)
                                 (-all means to back up all installed applications)
                                 (-system|-nosystem toggles whether -all automatically includes
                                    system applications; the default is to include system apps)
                                 ( is the list of applications to be backed up.  If
                                    the -all or -shared flags are passed, then the package
                                    list is optional.  Applications explicitly given on the
                                    command line will be included even if -nosystem would
                                    ordinarily cause them to be omitted.)

  adb restore            - restore device contents from the  backup archive

  adb help                     - show this help message
  adb version                  - show version num
[root@localhost ~]# 

Let's see if the smartphone is recognized:

[root@localhost ~]# adb devices -l
List of devices attached 
xxxxxxxx               device usb:3-1.6 product:zzzzzzzz model:GT_I9515 device:yyyyyy

[root@localhost ~]# 

It is, so let's start the backup.

[root@localhost phone]# adb backup -apk -all -s xxxxxxxx -f OUTPUTFILENAMEOFYOURCHOICE
Now unlock your device and confirm the backup operation.

Now you need to unlock your phone, it will ask you if you want to do the backup, and eventually it will ask for the encryption password. Answer, and the backup will start.