How to rsync to android
Actually using rsync over MTP/usb
It's easier than everyone is saying, first notice that when GVFS mounts the MTP mount it'll be available under. You can force this by opening the phone up in a graphical file-browser (thunar/nautilus/etc)
/run/user/$UID/gvfs
go in there. Assuming you have one mtp device, this should work:
$ cd /run/user/$UID/gvfs/mtp*
Find where you want to transfer the files too, and then rsync them to it
$ cd SanDisk\ SD\ card/Movies/
$ pwd # prints "/run/user/1000/gvfs/mtp:host=%5Busb%3A003%2C096%5D/SanDisk SD card/Movies"
$ rsync --verbose --progress --omit-dir-times --no-perms --recursive --inplace ~/Videos/ ./
Rsync options
-
--inplace
: I highly suggest using--inplace
without which mtp may want to copy the file a new, and then rename it to the old one. That may result in copying the file to the SD card twice: once for the mtp transfer to the SD card, and another time because the MTP driver may not support (mv), it may (cp/rm) under the hood to be safe. - read man rsync for a description of
--verbose
,--progress
,--recursive
but they're pretty self-documenting. -
--omit-dir-times
--no-perms
are required because mtp doesn't support that.
Using sshelper
I found this solution:
- Install sshelper on the device (no rooted device needed, available from google play market)
- In my WLAN the device is called "android". But you can use the IP, if you can't give the device a hostname.
Edit local ssh-config, to alter the default port for host "android"
.ssh/config
host android
Port 2222
- Start sshelper on device.
- Connect android device to you WLAN.
rsync -rvlc Music android:SDCardLink/
Update
I prefere -rvlc
to -a
since you get a lot of warnings since setting permissions and time-stamps does not work. The option -c
makes the second sync much faster.
I prefere -rvl --size-only
to -a
since you get a lot of warnings since setting permissions and time-stamps does not work. The option --size-only
makes the second sync much faster.
Unfortunately it needs some time for music apps to see the new files. Restarting the device helps.