23

I have rooted my device HTC Evo Design 4G and I try to adb pull /data data and it says "0 files pull 0 file skipped"

I was able to pull /System/build.prop. How can I pull the root folder?

2
  • 2
    Did you run adb root first? Commented Jul 4, 2014 at 6:35
  • 1
    Yes, but adb root was not success. No permission. But I could adb shell su. It gives #. Commented Jul 4, 2014 at 7:13

5 Answers 5

22

Files and directories below /data/data are protected from the "average user", so you cannot simply "pull" them unless the ADB daemon is running in root mode. Other than the file you were referring to (/system/buildprop is at least readable by all apps), folders below /data/data are "invisible" (except for root), so they cannot even be read.

To be able to use adb pull on them, you need to make your ADB daemon run in root mode first. Depending on the device, a simple adb root command might do that – but most devices will refuse to do. In those cases, you can use chainfire's adbd insecure: Install this app on your device, start it there, and manually switch to "insecure" mode. Now the pull should succeed.

Remark: It's called "insecure" because running adbd as root gives everybody with a computer and an USB cable access to everything on your device. Just in case you wonder.

3
  • Thamk you! Apart from the chainfire adbd insecure, Can I set ro.secure flag in build property? Can I use adb shell setprop ro.secure 0? Commented Jul 5, 2014 at 1:20
  • I haven't ever tried that, nor do I know exactly what that flag is for – so I cannot tell. (Btw: if you found the answer useful, you're welcome to "upvote" it (the SE way to say "thanks") – or "accept" it when it solved our issue ;)
    – Izzy
    Commented Jul 5, 2014 at 18:05
  • 1
    adbd insecure work for me :) Commented Jul 6, 2014 at 1:27
7

If your phone's rooted, there are three ways to go around this. The first one is to use ADBD insecure.

The other one is to move it to another folder with root and then pull it from there:

$ adb shell

shell@android:/ $ su
root@android:/ # mkdir /sdcard/data
root@android:/ # cp /data/data/* /sdcard/data
root@android:/ # exit
shell@android:/ $ exit 

$ adb pull /sdcard/data .
$ adb shell

shell@android:/ $ rm -r /sdcard/data/
shell@android:/ $ exit

I think you can build a script such as:

echo 'echo "mkdir /sdcard/data; cp $1/* /sdcard/data; exit" | su; exit' | adb shell
adb pull /sdcard/data .
echo 'rm -r /sdcard/data; exit' | adb shell

and save it somewhere.

Finally, the third option is chmod -R 1777 /data/data, but this is much more unsafe, so it's highly discouraged.

4
  • May I ask what $1/* refers to? Is it the /data/data directory?
    – emen
    Commented Oct 7, 2016 at 9:37
  • Use -r for copy Recursive subdirectories and files "cp -r /data/data /sdcard/data"
    – Monu
    Commented Feb 8, 2020 at 21:03
  • @Emen $1 would be the first argument provided to the script, in this case it would be referring to a directory. So if that script was in a file called extractdir.sh you could call it with ./extractdir.sh /path/to/target/dir.
    – h0r53
    Commented Feb 18, 2020 at 16:38
  • Use single quote inside double quote, otherwise $1 will be interpreted as literal $1 instead of parameter value echo "echo 'mkdir /sdcard/data; cp -r $1 /sdcard/data; exit' | su; exit" | adb shell
    – Monu
    Commented Mar 21, 2021 at 10:55
5

You cannot pull data folder directly since adb doesn't have file listing access to it. If you want to pull the /data folder you can do it via recovery ([Custom recovery, CWM/TWRP] run adb while device is in recovery mode, hopefully a custom recovery). Or as root, copy /data to another directory (sdcard) and pull it from there.

7
  • Thank you. But I was able to pull build.prop file in /System folder. adb shell su and then I can list files in root folder. I read in a Google search setting ro.secure build property to 0 will help pull /data. Is this true? If so is there a way to do it? Commented Jul 4, 2014 at 7:23
  • You can pull build.prop because /system has listing permission. You can change ro.secure=0 in your boot.img, but that is a really complex step. It would be easier to just install a custom recovery and do it from there. Commented Jul 4, 2014 at 7:28
  • Thank you very much! My primary purpose of the effort is implementing a forensic related application as a university final year project. I am really afraid, installing custom recovery will wipe out evidences from the device. Do you have any idea about the subject. Commented Jul 4, 2014 at 7:38
  • Adding to my previous comment - What is the use of adb shell setprop? Can't I use it in this case? Commented Jul 4, 2014 at 7:57
  • 1
    A forensic recovery program that relies on the phone being rooted and having debugging turned on doesn't sound very useful.
    – Dan Hulme
    Commented Jul 4, 2014 at 8:07
1

PART I: Getting all the files ready for an ADB PULL

This is what worked for me:

  • Make sure you're using the latest ADB version.

  • Start the ADB session: adb shell

  • Get SU rights once in the ADB session all you have to do it's type su like so: su. Then you'll notice that the $ becomes #.

    • The hash lets you know you're on SU mode.
  • Make a folder on the /sdcard of the device: mkdir /sdcard/data/

  • Head to the root of the file you want to copy.

    • For me, for example, I wanted to make a backup/copy of my apps and store it on my computer so: /data/app #
  • An example of what I get if I ls that folder:

root@m1:/data/app # ls
com.abtnprojects.ambatana-1
com.acr.rootfilemanager-1
com.amazon.kindle-1
com.android.chrome-1
com.android.mms-1
com.android.vending-2'
  • In order to copy recursively with the ADB cp command, use the option -R and since I wanted to copy everything in it, I used the wildcard * like so: cp -R */ /sdcard/data/

  • Once you press enter, if the file is fairly large it will obviously take a while to copy the files, so the cursor will idly blink for a bit, it will look like if not doing anything, BUT IT IS! it's copying the files, so don't panic! and don't stop the process!

    • If you want just open another ADB shell session and head to the folder where you're transferring the files and do an ls check and you should see that the empty folder is now getting populated with the files. Once the transfer is done, you'll get your shell back.
  • Head to the sdcard/data and make sure everything was copied ls:

'root@m1:/sdcard/data # ls
com.abtnprojects.ambatana-1
com.acr.rootfilemanager-1
com.amazon.kindle-1
com.android.chrome-1
com.android.mms-1'**

PART II: The ADB PULL

  • By this point, if you haven't created a folder on the target machine, do so. I conveniently created a folder called apps

  • Now, let's do the elusive recursive ADB PULL of all the files at once:

  • Make sure that you are logged out of the ADB session, since we've been on SU mode, we'll need to exit twice:
root@m1:/sdcard/data # exit
shell@m1:/ $ exit
  • From a normal shell session, run the adb pull, you don't have to use the -a option, I personally use it to keep the integrity of the files as much as possible. Run the command: adb pull -a /sdcard/data/ apps/

You should see something like this:

[ 69%] /sdcard/data/com.google.android.gms-1/base.apk: 74%

Once it's done:

/sdcard/data/: 296 files pulled. 5.1 MB/s (1193942288 bytes in 221.352s)

And Voila!

Side Notes:

  • Don't know if matters but I use a Mac.
  • If while on the ADB session you can't get "su privileges" either:
    • 1st: You probably need to give ADB root access
    • 2nd: "super user" it's not installed correctly
  • Double-check your commands
1
  • Don't I need to be rooted for that?
    – neverMind9
    Commented Jun 1, 2018 at 13:35
0

Working on my Android 7.1 device. Steps to get it working:

  1. Download the adbd insecure version by leroy at https://nofile.io/f/86605d8qsJs/adbd-Insecure-v2.00.apk
  2. Install on your phone.
  3. Run adb shell in your adb directory
  4. Type su so u can get the "#"
  5. Type setenforce 0
  6. Enable insecure adbd. USB debugging turns off
  7. Turn USB debugging on and off from developer options
  8. Turn insecure adbd off and on again.

You can now adb pull into your PC.

You must log in to answer this question.

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