--- title: Using rsync on Android to syncronise my Music library author: Never date: 12.01.2026 summary: As Spotify is getting enshittified by capitalism, keeping a music library is kind of essential. Here I use rsync to syncronise my library with my Android smartphone. --- # Setup Termux Install Termux using F-Droid. Update software repos. ```sh pkg update ``` Grant file access permissions using. ```sh termux-setup-storage ``` # Establishing an ssh connection If network (such as eduroam) is blocking ssh trafic between machines, open a Wi-Fi Hotspot on your Linux machine and connect the Android device to it before using `rsync` or `ssh`. ## Configuring Android Install the openssh server on Termux. ```sh pkg install openssh ``` Start the ssh server daemon. ```sh sshd ``` Get the ip address of the Android machine (in the Hotspot). ```sh ifconfig ``` ``` Warning: cannot open /proc/net/dev (Permission denied). Limited output. lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC) rmnet0: flags=4305 mtu 1280 inet 10.200.157.166 netmask 255.255.255.0 destination 10.200.157.166 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC) wlan0: flags=4163 mtu 1500 inet 10.42.0.200 netmask 255.255.255.0 broadcast 10.42.0.210 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC) ``` In this case 10.42.0.200. The ssh server should now be running and listening on port 8022. You can check by running ```sh nmap -Pn ``` For me `` whould be 10.42.0.200. Get the username. ```sh whoami ``` ``` u0_a700 ``` Set a password for this user. ```sh passwd ``` ## Connecting to Android via ssh Make sure you have an ssh key pair on the Linux system. If not generate one using `ssh-keygen`. Now connect to Android by `ssh`. ```sh ssh @ -p 8022 ``` # Syncronising files with rsync Install `rsync` on Termux and Linux. Make sure to keep your own openssl config. ```sh pkg install rsync ``` Now on your Linux machine, syncronise your Music library with rsync. ```sh rsync -av -e "ssh -p 8022" ~/Music @:/data/data/com.termux/files/home/storage/music ``` ## Refreshing the Android MediaStore Android uses a Database to store files. In order to play your music, this database needs to be refreshed. This can be achieved by a reboot or by using adb to manually refresh it. ```sh sudo dnf install adb ``` Connect the Android device via USB and see if it is listed. ```sh adb devices ``` If it is, restart adb in TCP mode with port 5555 ```sh adb tcpip 5555 ``` Connect to the device using its . ```sh adb connect ``` Refresh MediaStore. ```sh adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN -d file:///data/data/com.termux/files/home/storage/music/ ```