1

So I am using adb to copy all of my Android files to my Windows PC with this command: adb pull -a /mnt/sdcard C:\backup

And when it's done it says all x amount of files have been pulled, I can confirm that the number of pulled files matches the amount of files that reside inside the folder of my Android storage but when I check how many files are actually in the C:\backup folder, I see about 200 missing or in other words adb skipped about 200 files and did not copy them over to my C:\backup folder.

I understand that this could be due to path limit or due to some files containing characters in their filenames that Windows' NTFS file system just doesn't allow.

How can I see what files are actually being skipped? Is there a switch in adb or some trick?

  • 1
    You can instead use tar on device to create a tar archive with all files and stream that to your PC. May be tar works more reliable: android.stackexchange.com/a/194854/2241 If you device is not rooted remove the su part and adapt the path. – Robert May 23 at 11:49
  • @Robert I used adb exec-out 'tar c /storage/emulated/0/123.txt' > 123.tar but it just creates a corrupted tar archive. – computationalprince May 23 at 12:35
  • @alecxs /mnt/sdcard/ is internal storage and it is also the same as /storage/emulated/0 and no, I am not trying to pull things from a MicroSD, I am trying to pull all the files in the internal storage's root directory. – computationalprince May 23 at 12:39
  • The tar archive was corrupted (what type of corruption)? May be you are facing a totally different problem with a broken USB cable and/or port. What adb version do you use the latest from Android SDK? – Robert May 23 at 13:29
  • @Robert No matter what file or how many files I add to the tar archive with that command it always outputs a 90 byte archive that 7z can't open because it says "Is not archive". I am using the latest adb, I literally downloaded it today. Tried multiple USB cables, same issue. – computationalprince May 23 at 15:37
4

Just pulling all files via adb to a WIndows computer has multiple problems:

  1. Android/Linux allows multiple files in one directory that just differ in their case.
  2. The file-system on Linux allow characters in file- and directory names that are disallowed on Windows
  3. Some file-names are completely disallowed on Windows which are just regular file-names on Linux/Android
  4. There is a path limit as you have already mention that may cause trouble

Hence the best solution to create a full backup of the sd-card is to pack all files into one tar archive as all file-system limitation of Windows can bypassed using this method.

Via adb you create a full backup of the sd-card using the following command:

adb exec-out "cd /storage/emulated/0 && tar c * -" > sdcard.tar

This command creates the tar archive on the device and directly streams the data of the tar archive through adb to your PC and saves it there as sdcard.tar.

| improve this answer | |
  • @alexs You are correct 1 is not possible but 2 and 3 are valid. Filenames with backslash are possible and reserved names like aux and com1 are also possible just as an example. – Robert May 23 at 18:39
  • oh no how stupid from sdcardfs. thought behavior is same as vfat – alecxs May 23 at 18:48
  • I wish this worked, but I simply get a corrupted tar archive no matter what. – computationalprince May 23 at 19:01
  • 1
    @computationalprince Right, access to that folders is only possible via adb. Hence if you really want a warking tar you have to copy the busybox binary to sdcard in Termux. Them in adb copy it from sdcard to /data/local/tmp and restore the executable flag via chmod. Then you can execute tar via /data/local/tmp/busybox tar. – Robert May 24 at 11:08
  • 1
    @Robert You were right! I did everything you said and now when I run your command with the new tar path e.g. adb exec-out "cd /storage/emulated/0 && /data/local/tmp/busybox tar c * -" > sdcard.tar I get a healthy tar archive with all the files. Thank you a lot! – computationalprince May 24 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.