Last active
December 29, 2024 19:03
-
-
Save thomas479/7ea65242983b2ad6e75fe0d69b0e2763 to your computer and use it in GitHub Desktop.
Android adb pull all files as tar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
adb exec-out 'tar --dereference --create --exclude=sdcard/Android/data/com.spotify.music/ \ | |
sdcard/ 2>/sdcard/backup-errors.txt' | \ | |
dd of=backup-$(date +%Y%m%d).tar && \ | |
adb shell cat /sdcard/backup-errors.txt |
I'm curious if it's possible to restore the tarball using
exec-in
. 🤔
Unless there are file permission issues, why not? Something like this should be possible (disclaimer, the command has not been tested):
dd if=backup-file.tar | \
adb exec-in 'tar xpvf - 2>/sdcard/restore-errors.txt' && \
adb shell cat /sdcard/restore-errors.txt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All the Linux / Android processes have at least three file handles. 0 is for standard input, 1 for standard output and 2 for standard error. In shell scripts, when used, '<' is used to send a file to the standard input of the program, '>' is used to save the standard output to a file, and '2>' is used to save the standard error to a file.
The command line after
adb exec-out
which is within the single quotes is run within the phone. As thetar
command emits by default the tar archive through its standard output, you don't want to garble it with the warning and error messages emitted by the sametar
command.