I need a way to transfer files to and from my Android phone in bulk. The main purpose is to update my music directory.
Updating music via a find
command with an -exec adb push {} \;
argument overwrites existing files and so is suboptimal.
I got fixated on the idea of mounting Android as a filesystem. This was
I tried various mtp
tools, such as mtpfs
, simple-mtpfs
and go-mtpfs
. I received broken pipe error messages even with small payloads. Then I tried mounting with gvfs. This was so slow it was unusable.
I realised that mounting was just adding additional complexity, and rsync
ing over a network would give precisely the desired behaviour.
In Termux:
pkg add rsync openssh
adb push ~/.ssh/id_rsa.pub sdcard/
Then, in Termux, move to .ssh/
mv /sdcard/id_rsa.pub .ssh/
Append to known hosts.
cat .ssh/id_rsa.pub >> .ssh/known_hosts
To ssh
in via usb:
adb forward tcp:8022 tcp:8022
ssh localhost -p 8022
Rsync to phone:
rsync -av -e 'ssh -p 8022' ~/archives/music/* localhost:storage/shared/Music/