I use Simple MTPFS to access the Android phone and rsync to sync the music files.
./mount_android.sh ~/Documents/temp/android
Trying to mount android to '/home/mat/Documents/temp/android'.
Could not retrieve device storage.
For android phones make sure the screen is unlocked.
Error, can't connect to android. Is it connected and you granted permission?
The security prompt only shows up in the first time, unlock your phone and grant permission.
After granting permission, re-run this script with same parameters.
[ Unlock phone and grant permission ]
./mount_android.sh ~/Documents/temp/android
Trying to mount android to '/home/mat/Documents/temp/android'.
Success. Android connected.
./sync.sh ~/Music ~/Documents/temp/android/Music
sending incremental file list [ rsync ]
...
./umount_android.sh ~/Documents/temp/android
Trying to umount android from '/home/mat/Documents/temp/android'
Android umounted!
Profit!
Thanks Björn Bidar for giving hints about best practices in shell script programming.