How can I connect to my android device to rsync music (or other stuff)?
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/
-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.
Unfortunately it needs some time for music apps to see the new files. Restarting the device helps.
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)
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/ ./
--inplace: I highly suggest using
--inplacewithout 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
--recursivebut they're pretty self-documenting.
--no-permsare required because mtp doesn't support that.
rsync backup for Android can be configured to sync in reverse, that is from a Linux host to Android device.
And with the help from Llama one can configure the Android device to rsync automatically on specific conditions, e.g.:
- at 5 am,
- when the phone is connected to a specific Wi-Fi, and
- when it is charging.