4

A simple requirement over which I am breaking my head!

I want to keep a folder on my computer in sync with the folder on my android device. There are times when the file on the computer will be 'new' and times when the file on the Android device will be 'new'.

Both the devices are connected to the same wifi network. How do I do that?

Here is what I have tried already.

  1. Syncthing - mixed bag results. Syncs at times. Does not at others. Unreliable. So, unusable
  2. Connecting the Android device over KDE Connect. Try Unison to sync two folders. Fails giving an error:

f1.txt — transport failure • Error in renaming /home/user/.config/kdeconnect/99899/kdeconnect_sftp/99899/storage/emulated/0/sync-dir/.unison.f1.txt.01a8d60d253c276456cc2d6db4c37c9b.unison.tmp to /home/user/.config/kdeconnect/99899/kdeconnect_sftp/99899/storage/emulated/0/sync-dir/f1.txt: Operation not permitted [rename(/home/user/.config/kdeconnect/99899/kdeconnect_sftp/99899/storage/emulated/0/sync-dir/.unison.f1.txt.01a8d60d253c276456cc2d6db4c37c9b.unison.tmp)]

deshmukh
  • 4,121

1 Answers1

1

I solved similar problem by the following actions.

Steps for Android device:

  1. switch Wi-Fi on;
  2. install SSH server - SimpleSSHD;
  3. start SimpleSSHD server.

Steps for computer (my laptop runs Ubuntu 16.04.5 LTS MATE):

  1. switch Wi-Fi on (in the same network as Android);
  2. enable key-based SSH authentication by running scp -P 2222 /home/$USER/.ssh/id_rsa.pub android@11.22.33.44:/data/data/org.galexander.sshd/files/authorized_keys (where 11.22.33.44 is an IP address of the Android device) and enter password shown on screen of Android device in SimpleSSHD window.

  3. install SSH FS with sudo apt-get install sshfs;

  4. create SSH FS mount point (/media/MyAndroid in my case);
  5. install FreeFileSync and create synchronization job for /media/MyAndroid and local folder;
  6. mount Android device with sshfs android@11.22.33.44:/storage/sdcard1 -p 2222 /media/MyAndroid/ (where /storage/sdcard1 is a folder to be mounted, 2222 is SSH server port), enter SSH password when prompted;
  7. launch FreeFileSync job when needed to synchronize Android device and local folder;
  8. unmount SSH FS mount with sudo umount /media/MyAndroid or fusermount -u /media/MyAndroid (and then one can stop SimpleSSHD on Android device).

This looks first-time difficult, but works great.

You can try to automate this with RealTimeSync (I did not tried, I sync twice a week manually).

Note: if you want to sync external SD-card (normal dedicated microSD) you need to get root access and install SD Card Fix (tested on my Android KitKat 4.4.4 device).

N0rbert
  • 103,263