Linux rsync into Android (termux)

very long story happend to me today would take days to be written to sync my massive media dir to be 1:1 with my android phone usually I used jmtpfs it’s good but I had to mess with udev rules for kernel usb autosuspend (not configured on archlinux by default) and more headaches until I came to

  • rsync
  • sshfs
  • sshd (termux)

I would simply move and delete files around after while sync them to my android phone over network for destination to be 1:1 as my source directory

on my phone with termux :

# if openssh not install
# pkg install openssh
# set a user password with passwd
passwd
sshd
#default port is 8022 not 22 because Android's security rules block normal apps from using any port number below 1024

from my archlinux pc :

# now i mount my phone using sshfs over sftp
sshfs [email protected]:/sdcard/ phone/ -p 8022
# and simply rsync my media direction
rsync -av --size-only --partial --delete /mnt/base/mcore/ phone/mcore/

that’s saved much of my time around 3000 files get removed added automatically
with the help of rsync

also special thanks for @hydn for his amazing blog about rsync it helped me understanding it better


11 Likes

Cool, I’ve never thought about using rsync for my smartphone.

I’ve been using Syncthing for ages to synchronise my computer, smartphones and tablets.

Thanks for sharing!

4 Likes

If you want to go the application route there is copyparty on github.
It supports phones also.

6 Likes

This sounds like what I used to do to sync my backups to Android:

rsync --verbose --progress --omit-dir-times --no-perms --recursive --inplace --delete '/run/user/1000/gvfs/sftp:host=<serverName>.<domainName>,user=<userName>/mnt/tank/backup/Backup_Offsite' '/run/user/1000/gvfs/mtp:host=%5Busb%3A003%2C014%5D/SanDisk SD card'

At some point, it became too much trouble with FAT32’s 4 GB file size limitation. The documentation was unclear whether Android could reformat the microSDXC card as exFAT or EXT4 to surpass 4 GB. By that time, I was uneasy with Google possibly having access to my backups…even if they were encrypted and not synched to a Google account.

3 Likes

rsync and scp commands can be such life saves and time savers. Nice job! :smiling_face_with_sunglasses:

2 Likes

I have been trying to move .mp3 and .mp4 files between my Linux machine to my android device over the network all summer long! (Mostly unsuccessfully :laughing:) I’ve got to try this, glad you shared!

3 Likes

There is no Android App in releases?
How does this work?

In GrapheneOS forum no hits for “copyparty”

please explain how-to use this. Thanks!

2 Likes

Instructions for android and ios are on the github page.

2 Likes