Use Rsync to Transfer Files to/From Android Phone
I used Sony phones for the last 10 years, which always allowed the use of microSD cards. Recently Sony stopped producing the Xperia 5 series, which would have had an okay size (I actually would love the Xperia 5 compact series to come back!). I am not going to get an even bigger phone, therefore I had to switch brand. Reasonably performing phones do not have microSD slots anymore. Hence, me learning about the crappy place that is called MTP and hard to use wifi transfer tools.
Luckily you can use some open-source tools (for now, syncthing was already discouraged from publishing on the play store).
The alternative I chose is Termux which can install and run sshd and rsync.
- I already had F-Droid installed on my phone for other apps.
- Install Termux
- Inside Termux set your users password using
passwd - Figure out your Phone’s IP Address and username with
ifconfigandwhoami - Install ssh and rsync
pkg upgrade pkg install openssh rsync - Ask for file-system access permissions for Termux
termux-setup-storage - Start SSH server
sshd - Copy your ssh public key to the Android device for later ease of use
ssh-copy-id -i ~/.ssh/id_ed25519.pub u0_a444@192.168.1.113:storage/downloads/ - And finally use for example this command to copy from macOS to the phone, without adding useless cruft:
rsync -av -e "ssh -p 8022" --exclude="._*" --exclude=".DS_Store" --exclude=".trashed*" . u0_a444@192.168.1.113:storage/downloads/
To copy files at a later point in time, do steps 7. and 9. again.