How to sync folders between Android and Linux?

The idea is that files saved in some folder on Android are automatically transferred to a folder on your Linux-based desktop computer, and vice versa. This should happen locally, without a "cloud storage" somewhere on the Internet.

For now, the best solution for automatic syncing is the commercial, closed-source app FolderSync as recommended by LinuxJournal.

 

I tried a bunch of alternative solutions, but they would not work as intended:

SparkleShare Android app

The SparkleShare for Android app [source code here] Allows to download files from a Sparkleshare repository only, not to upload them. Also the downloading has to happen manually.

Installation:

  1. Install git-daemon on the computer that should run the SparkleShare server. (This is maybe not needed, as a SparkleShare server is nothing else than a git server, and it is set up below.)
  2. Install the SparkleShare server on your PC or a web server where you have sufficient right, according to these instructions.
  3. Install sparkleshare-dashboard according to these instructions, on the computer that also runs the SparkleShare server. (In the step to start teh redis server, use this command on Ubuntu: redis-server /etc/redis/redis.conf).
  4. Install SparkleShare for Android on your phone.
  5. Insall SparkleShare, see Install SparkleShare 1.0 In Ubuntu (Dropbox-Like File Synchronization Tool). Because, even if you installed the SparkleShare server on your own local PC, you can not directly put the files into the server's directory to be synced. It will only sync files in directories that are watched, and that is done by the SparkleShare client.
  6. Configure this all.
    • When trying to start sparkleshare-dashboard, it may complain about not finding some nodejs module. In its directory, call "npm link <modulename>" for every module it complains about, to solve this [source].
    • Note that the SparkleShare client only works with its own generated SSH key. It will give you the SSH pubkey as "unique link code". Put it in the ~/.ssh/authorized_keys file on the SparkleShare server's host, of the user running the SparkleShare server. This will give the SparkleShare Desktop client access, while the Android client gets acvcess by the "device pairing" function of sparkleshare-dashboard.
    • Note that the link code required by SparkleShare for Android is NOT the SSH pubkey handed out by the SparkleShare desktop client as "unique link code", but instead the 10-letter or so code that appears as text and QR code when using the "device pairing" function of sparkleshare-dashboard.
    • When you can see folders in the sparkleshare-dashboard web frontend, you should be able to see them in a paired Android device, too. But I only was able to get to this point by making the SparkleShare repos "public" in config.js; this is not the correct way of course if you want private data syncing, but a good first step when configuring it all:
      exports.folders = [
        { type: 'git', name: 'Private GIT folder', path: '/home/storage/sparkleshare-data-local', pub: true }
      ];
    • As said, I was not yet able to get the access permissions of the sparkleshare-dashboard app right to access SparkleShare repositories. I don't even know if the user created for sparkleshare-dashboard needs to conform to any other user (SparkleShare server user maybe? probably not, as that was set up without a password).

Gidder to host a SparkleShare repo

Gidder is a full-fledged Android git server. Normally, any git server could be used to host a SparkleShare repository, and this would make this a very lightweight, nice solution, without the sparkleshare-desktop, nodejs, redis database etc. needed by the SparkleShare for Android app (and requiring installation without the package format …). However, Gidder cannot be used with SparkleShare, as it does not support SSH key authentication (only password authentication) [source], and SparkleShare only supports this (and no password authentication).

And in any way, this solution would still need a "git commit" and "git push" action on the Android device to get file changes to the desktop computer. While here, we want something automatic.

dvcs-autosync or git-auto-sync

See the dvcs-autosync website and git-auto-sync website. This runs on the Linux host and can auto-push to a git repo, probably including one hosted by the Gidder Android-based git server (I did not test). However, still the problem remains that on the Android side, no auto-syncing to a repository seems possible.


Posted

in

,

by

Tags:

Comments

4 responses to “How to sync folders between Android and Linux?”

  1. Jacob

    I have used different frontends for rsync on my Ubuntu machine to get the job done. It really works well. I have used it over USB, which is exactly what I wanted becuase I don’t have internet access at home so wi-fi didn;t make sense for me. I think it’s also quite possible to use over wi-fi using ssh or something like that.

  2. Ion Trandafir

    Very interesting post, it actually doesn’t present the hoped solution. Still looking for the magic automated folder sync between Android and Linux PC without cloud services.

  3. @Ion: Same setting here: Linux PC and Android tablet and wanting to avoid the cloud. Since a few weeks I use a solution with rsync, and I’m finally happy with that. Give it a try 🙂

    It’s not automagic – I have to execute a command to sync directories. But I could do this every few minutes with a cron job on the computer, of course.

    This solution is soooo much better than MTP on devices that only offer MTP (and not USB mass storage). Because the MTP implementation is horribly buggy on even the latest Android.

  4. andrew

    Why no body suggest syncthing ?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.