⋔ Home ⋔ About ⋔ Hire Me ⋔ Links ⋔ License ⋔ Archives ⋔ RSS ⋔
CONTENT WARNING (CUSSING)
490 words by attila written on 2024-12-25, last edit: 2025-03-15, tags: android, shell, unix
⋔ Previous post: Encounter ⋔ Next post: Offline Search for Privacy
Just a quick note while I'm still pissed and doing it: trying to get my pictures off of Android in a clean way is a fucking mess, and OK, it's probably my fault. Because REASONS. Whatever. This is what I end up doing over and over:
$ adb shell tar -X sdcard/xclude.txt -C sdcard/Pictures -zcf - . | \
tar -C Desktop/pix/20241225-android-thang-fulldump -zxvf - | \
grep -v --line-buffer '^\./$' | \
tee -a tmp/xclude.txt
./IMG_20241224_162612.jpg
./IMG_20241224_162721.jpg
./IMG_20241224_162728.jpg
./IMG_20241224_162840.jpg
... bad cable or whatever kills the serial connection
gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
... by this point the connection is back
$ adb push tmp/xclude.txt sdcard/xclude.txt
# lather, rinse ...
$ adb shell tar -X ...
Since whatever tinyshell/rootbox type thing they have on the droid
side does not have rsync
, I'm stuck keeping my own list of files I've
already transferred on the side, in xclude.txt
, and then pushing it
to the droid so I can pass it to tar
which at least supports the
-X
option. I then echo the names of the files I've transferred on the
receiving (e.g. moderately reasonable) end, but filter out the stupid
./
that tar
spits out, because then I'll exclude everything.
See? Simple. Practical Unix trix for the whole family. FWIW I have written a script to automate this, but it still annoys me I had to do it:
#!/bin/sh
target=$1
today=$(date +%Y%m%d)
[ x"$target" = x ] && target=$HOME/Desktop/pix/${today}-android-thang-dump
[ ! -d $target ] && mkdir $target
echo "## target: $target"
tmp=${TMPDIR-$HOME/tmp}
xcl=xclude.txt
my_xclude=$tmp/$xcl
droid_xclude=sdcard/$xcl
[ -f $my_xclude ] && {
ls -l $my_xclude
adb push $my_xclude $droid_xclude
}
adb shell tar -X $droid_xclude -C sdcard/Pictures -zcf - . | \
tar -C $target -zxvf - | \
grep -v --line-buffer '^\./$' | \
tee -a $my_xclude
Android is a nightmare so long as you continue to maintain the delusion that it is anything like Unix. Also, cables suck. Just generally. But more specifically, cables go bad here, where the salt air is beyond strong, so much faster than I've seen anywhere else it truly shocks me. Cables, USB ports, whatever is exposed to, you know, the AIR, it's all going to die much sooner than you would think here.
So my USB cable to the droid is probably going bad, or the USB port (I've tried several), or the connector on the droid side, or some damned thing causes my connection to the droid to go bad every, you know, whenever. I adapt, using the tools in the best way I know how, and cuss about it here. Yay.