Rsync to mtp mounted android does not work
Solution 1:
Not sure if you need a rooted device for this (I only run rooted LineageOS and am not familiar with other flavours). In LineageOS, /system/xbin/rsync exists by default, else, connect your phone to your PC and start a terminal and execute all of the commands below in the PC's terminal:
sudo apt install wget adb wget -O rsync.bin http://github.com/pts/rsyncbin/raw/master/rsync.rsync4android adb push rsync.bin /data/local/tmp/rsync adb shell chmod 755 /data/local/tmp/rsync adb shell cp /data/local/tmp/rsync /sdcard/rsync.bin adb shell /data/local/tmp/rsync --version
- create a configuration file
adb shell 'exec >/sdcard/rsyncd.conf && echo gid = 0 && echo uid = 0 && echo address = 127.0.0.1 && echo port = 1873 && echo "[root]" && echo path = / && echo use chroot = false && echo read only = false'
- start the rsync daemon on the device
# on regular Android adb shell /data/local/tmp/rsync --daemon --no-detach --config=/sdcard/rsyncd.conf --log-file=/proc/self/fd/2 # on LineageOS adb shell rsync --daemon --no-detach --config=/sdcard/rsyncd.conf --log-file=/proc/self/fd/2
- on a different shell window, start port forwarding
adb forward tcp:6010 tcp:1873
- happy copying
rsync -av --progress --stats --partial rsync://localhost:6010/root/sdcard/DCIM .