8

I tried to sync ogg-audio-files to my android device like this:

rsync -av piano /run/user/1000/gvfs/mtp\:host\=%5Busb%3A002%2C005%5D/SanDisk/Music/

===> rsync -av piano/ /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C007%5D/SanDisk/Music/
sending incremental file list
rsync: failed to set times on "/run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C007%5D/SanDisk/Music/.": Operation not supported (95)
...
foo-bar/one.ogg
...
rsync: mkstemp "/run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C007%5D/SanDisk/Music/foo-bar/one.ogg.0gzy9t" failed: Operation not supported (95)

But only the directory got created. No file was transfered:

===> find /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C007%5D/SanDisk/Music/piano

/run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C007%5D/SanDisk/Music/piano/foo-bar

How to rsync between my android device and my Ubuntu PC?

I found a work-around: I unplugged the micro-SC card from the android device and inserted it into the sd-card reader of my laptop. But a solution where I don't need to do this would be nice.

guettli
  • 1,777
  • Your "mounted Android" device is probably a VFAT filesystem (see lsblk -f) and doesn't support all the times (atime, mtime, ctime see man ls) that rsync wants to set. perror 95 tells me OS error code 95: Operation not supported. In a similar problem, I ended up using cp instead. Do you really need all the bells and whistles of rsync? – waltinator Aug 11 '19 at 15:30
  • 1
    @waltinator I don't need all times (atime, mtime, ...). But I want the copy to be fast if I execute it some days later. I only want to transfer the few changes, not all files again. – guettli Aug 12 '19 at 07:38
  • Personally I found SSH/SFTP more convenient. See https://askubuntu.com/a/981883/66509 . – N0rbert Aug 15 '19 at 19:48

4 Answers4

2

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 .
Yuv
  • 308
  • I have to remove the lines gid = 0 and uid = 0 from the config file (otherwise, I got setgid failed rsync error), and I have to be inside the phone with a adb shell to start the daemon. Thanks! – Luis A. Florit Apr 18 '20 at 20:33
0

For a couple of simple solutions, you can try one of these:

  1. (My preferred) Install an FTP server on your phone, then use a GUI program (like Filezilla) to transfer the files. I get consistently good transfer rates (6M+) on a 2.4G network.
  2. Use a service like AirDroid. It's not great with large files (4G+), but it's great with smaller ones. The free version only allows 200M/month, though.
ajgringo619
  • 1,172
0

Today I updated my music on my phone too. I could run

 rsync -vrih --omit-dir-times --no-perms piano /run/user/1000/gvfs/mtp\:host\=%5Busb%3A002%2C005%5D/SanDisk/Music/

and it worked slowly.


There is an other option --inplace to make it faster, but i got Operation not supported (95) errors too.

Boba Fit
  • 1,633
0

rsync and cp did not work for me. They all fail with an error like:

cp: cannot create regular file

The solution: gio copy

Bonus: It's already included on Ubuntu systems.

Example usage:

gio copy <src file> <destination mtp folder>

This doesn't work recursively for folders, but using:

gio copy source_folder/* <dest> will get every file in a folder.