34

I would like to ask if it possible to backup and restore all Android Settings and applications through ADB.

I tried:

adb backup -all
adb: unable to connect for backup

It is not working, while all other commands are working.

Is it possible to use this bmgr ?

3
  • i am using adb 1.0.29 on win7-64 and get the error adb: unable to open file ./backup.ab when executing adb backup -all. does adb devices find your android?
    – k3b
    Commented Jan 17, 2012 at 19:42
  • yes I can see the device id.
    – salamis
    Commented Jan 17, 2012 at 19:53
  • I've had a similar issue when submitting multipe package names on the command line. The problem was (is) the number of packages to backup is too long. I needed to split it in multiple command calls Commented Dec 17, 2016 at 13:14

7 Answers 7

9

Make sure debugging is enabled and the device is connected. Also, remember to actually select the "backup my data" button on the device itself (the device requires confirmation). If you don't see such a screen on your device, you're quite possibly running a pre-ICS (< 4.0) phone, which will unfortunately will not have the feature.

Also, bmgr is not a solution for this- It's a tool for testing apps that handle their own backups using the backup API by manually firing the "backup" and "restore" methods on the backup agent in the application, not shelling into the device and copying data to/from the development machine.

2
  • Yup - for me the problem was old version of Android on my phone, pre 4.0. Thanks!
    – nealmcb
    Commented Aug 5, 2015 at 14:20
  • Does this actually include settings/data?
    – Nobody
    Commented Feb 2, 2018 at 12:35
7

Here is my command for backing things up

./adb shell ls -l -a | grep '^[^l]' | sed -e 's/^d.* \([^ ]*\)\r$/mkdir sav\/\1; .\/adb pull \/\1 sav\/\1/' -e 's/-.* \([^ ]*\)\r$/.\/adb pull \/\1 sav\/\1/' | /bin/bash
  1. list all files
  2. ignore links
  3. for
    • files : output an adb pull command
    • directories : make the dir (in case we pull sth empty) and output an adb pull command
  4. execute everything in bash

There are some files where I get a permission denied - but as this backup is made in order to root the device, I can not get more permissions :(

2
  • 1
    This indeed appears to backup all files (minus the "permission denied" bits) even on older Androids (in this case, Gingerbread 2.3.3). I use this variant (added -p param to mkdir to avoid some error messages and removed ./ in front of ./adb): time adb shell ls -l -a | grep '^[^l]' | sed -e 's/^d.* \([^ ]*\)\r$/mkdir -p sav\/\1; adb pull \/\1 sav\/\1/' -e 's/-.* \([^ ]*\)\r$/adb pull \/\1 sav\/\1/' | /bin/bash Commented Nov 6, 2013 at 7:53
  • 3
    A much simpler way to do a recursive backup of all files, without needing any fancy regex is "adb pull /."
    – JC Hulce
    Commented Feb 2, 2016 at 1:14
6

If I understand you correctly, this link might be what you are looking for. To summarize:

1) Run adb devices to make sure your device is attached.

2) Run adb pull /data/app ./ to grab all the app APKs and put them in the current folder.
a) Or Run adb pull /system/sd/app ./ to get apps on the SD card.

3) Settings are located in various places, so find out where and then use the same adb pull command to grab them.

And then the link details how to restore based on Mac or Windows.

Alternatively, it looks like the bmgr command you mentioned would also work with a few simple commands (adb shell bmgr backup <package> to backup and adb shell bmgr restore <package> to restore). What more are you looking for?

3
  • 1
    As Alexander Lucas notes in his answer below, the bmgr command is a tool for developers to test app backup/restore. It does not actually copy any data off the device, so its unlikely to be useful.
    – P.T.
    Commented Oct 3, 2012 at 3:16
  • Doesn't work on adb 1.0.30 with Gingerbread device: pull: building file list... 0 files pulled. 0 files skipped. Commented Nov 6, 2013 at 7:54
  • Your adb pull will not work on non-rooted devices for private app data. And bmgr is only for controlling googles cloud backup
    – Murmel
    Commented Aug 24, 2016 at 10:36
2

problem is probably due to more than one device/emulator connected.

check adb devices if it shows more than one device then it might not be able to connect specialy to emulators.

run adb usb it will restart other devices, then disconnect/reconncet usb cable, now run

adb devices

it should show only one device.

now do

adb backup -all

and you should be good to go :)

1
  • what I would have to do if I use the command locally via a terminal emulator for android? Commented Feb 8, 2015 at 23:49
2

Make sure to run the SDK update and specifically check the box for Google USB Drivers and update the SDK.

After enabling USB debugging on your device and plugging into your PC, you should get a prompt about installing drivers. Even if its successful open device manager and find your phone, right click and update drivers and point it to the Google USB driver folder in the SDK > Extras > Google USB and let it update the drivers.

Then you should be able to pull full backups off your device.

1
  • This fixed the issue for me when I was having it. The drivers were not the issue, but the ADB version itself was too outdated. Commented Jul 21, 2014 at 14:27
1

I have a GS4 that I needed to backup and unfortunately ran into this error. after a bit of head scratching (and swearing) I found a fix that I hope will work for you. I was able to find this by just running abd and scrolling through the help documentation. I found that -d is a parameter that "directs command to the only connected USB device". So after plugging and chugging I got it to work for me. The command I used was:

adb -d backup -apk -shared -all -f C:\Users\NAME\backup.ab

Hope this works for someone having the same issue I had.

0

I had the same issue and am also pre-ICS. What I did to work around it was used an ls of / and awk (with grep to skip links) to create a batch file that pulls each actual directory onto a directory on my PC.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .