• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

Question How to get full backup of sdcard?

Search This thread

scarlion

Senior Member
Mar 15, 2015
65
4
Previously I could just plug my phone into my computer and run "adb pull -a /sdcard ." (Android 8) But that command doesn't work anymore now that I have a Pixel 5a with Android 11, it's filled with errors, such as:
Code:
adb: error: failed to copy '/sdcard/Android/data/com.alltrails.alltrails/files/tiles/tile_cache.db-wal' to './sdcard/Android/data/com.alltrails.alltrails/files/tiles/tile_cache.db-wal': remote open failed: Permission denied

This is some random app file, and I'm sure there are others too with weird permissions which cause adb to quit as soon as it has the error.

I've read that I could use a command like this:
Code:
adb exec-out "tar -ch sdcard | gzip" > sdcard_backup.tar.gz
but this just produces a corrupted archive because "tar" can't read all of the files either and so the error messages get inserted into the archive.

Any other ideas to simply get a full backup of /sdcard? Thanks
 

jcmm11

Recognized Contributor
Feb 10, 2012
3,585
3,600
Google Pixel 4a 5G
Previously I could just plug my phone into my computer and run "adb pull -a /sdcard ." (Android 8) But that command doesn't work anymore now that I have a Pixel 5a with Android 11, it's filled with errors, such as:
Code:
adb: error: failed to copy '/sdcard/Android/data/com.alltrails.alltrails/files/tiles/tile_cache.db-wal' to './sdcard/Android/data/com.alltrails.alltrails/files/tiles/tile_cache.db-wal': remote open failed: Permission denied

This is some random app file, and I'm sure there are others too with weird permissions which cause adb to quit as soon as it has the error.

I've read that I could use a command like this:
Code:
adb exec-out "tar -ch sdcard | gzip" > sdcard_backup.tar.gz
but this just produces a corrupted archive because "tar" can't read all of the files either and so the error messages get inserted into the archive.

Any other ideas to simply get a full backup of /sdcard? Thanks
I'm guessing that you're not rooted. That means that you probably won't be able to access most (if not all) of Android/data due to scoped storage restrictions.
If you change the tar command to
tar -chzf sdcard_backup.tar.gz sdcard
you should at least split out the errors from the data. The z option tells tar to compress the output using gzip. No need to explicitly pipe it through an external gzip program. f tells it that the next string is the output file name.

For the full tar manual see

A good file explorer should be able to get access to the restricted directories so you could use that to copy the data from there. I'm not sure about restoring in this case though since permissions may not be properly preserved.

If you are rooted then you can use tar to grab everything. There are options to preserve permissions but I would use the /data/media/0 path for that (path may not be correct. I'm going by memory since I'm not currently rooted and can't see the necessary directory structures).

I'll follow up here eventually once I do root, hopefully in a few days.