Skip to main content


Now the first "public beta" of my little "adbsync" script is tagged and available at

https://codeberg.org/izzy/adbsync/releases

Should be stable enough to be released to the public (though its code was public from the very beginning). adbsync lets you sync directories between your #Android device(s) and your (#Linux) PC without any special app, just utilizing things like rsync, adb, adbfs – and jq (to parse the JSON config file).

Give it a try, feedback welcome :awesome:

Peter Vágner reshared this.

Before I checked the Readme in the repository, I wondered how adbsync compares to adbfs and Syncthing. I checked and I'm pleasantly surprised!

I'm in the process of migrating all my devices to use Syncthing (via Wireguard). But I will give it a think! Sometimes I wondered whether some faster, more controlled, and direct means might be easier for some use cases. adbsync looks like it has potential here! (I used USB-cable-based data transfer and like the idea for various reasons.)
@floppy Syncthing requires a client on each device involved, which I didn't want. SSH would have been ideal, but again is not available per default on the Android devices. So this approach was the best way for me. Unfortunately adbfs has issues with some attributes (especially timestamps), so I had to work around that. But apart from this, it works fine for me with 3 devices: what's not connected (or disabled in the JSON) is simply skipped, all else processed properly. (1/2)
@floppy (2/2) Give it a try and please let me know how it went – and especially where things need fixing, including the instructions. You can use the issue tracker there, a ping here on the Fedi is also fine. I hope you enjoy it – and if so, you might also enjoy one of my other projects: Adebar (also on Codeberg) 😃
Thank you a lot for the detailed explanation!

I was bothered by similar issues (installing Syncthing, lack of SSH server). Will definitely try out! Also I'm curious how well it performs on non-rooted devices (that performant, but pesky Fire HDX).

I like the rationale behind Adebar! Will have a closer look soon!
@floppy adbsync does not use any "rooted features". It uses adbfs-rootless (sic!) to access the Android file system, and some (rootless) ADB calls to adjust timestamps (when syncing TO the device, as adbfs doesn't support all attributes). Depending on the directory size, it' not the fastest (I e.g. notice syncing my TiBu/Seedvault backup directories always takes several minutes even when just synced 5 minutes before).
(1/2)
@floppy (2/2) but then, high performance is not on the top of my list, reliability is. Once I'm satisfied all is working as it should (which meanwhile seems the case, hence the tag; I even dared enabling deletion with one-way syncs) I'll set up a nightly cron job at e.g. 4 am. No need to watch it live. Devices connected at the time will be synced, and I can watch the logs anytime later if I wish to.

Adebar: great, take a look at the example docs it generated: https://izzy.codeberg.page/adebar/
I think it's a pretty elegant solution to use adbfs for elaborate syncing. I tried to go that direction in the past, but I think my old hardware got in the way in the end.

I had a look at adbsync and I like it a lot! I had some minor issues (details follow), but it seems to be working nicely. Pretty impressive you went all the way through directory tree traversal and working around the timestamp limitations!
I had problems with spaces and special characters in filenames when syncing and could get it fixed by adapting sync2dev() a little.

https://termbin.com/w1ls

I still get some strange rsync errors, but they don't seem to impact anything.

rsync: [sender] readdir("[local-path]/[android-path]/."): Input/output error (5)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1326) [sender=3.2.4]
@floppy 1) don't use spaces in names, they always cause trouble
2) could you please put that into an issue in the repo, or a PR?
3) yes, those errors happen when syncing TO the device, Guess why I had to work around that with some special rsync options and manual timestamp adjustments 🙈 That's caused by adbfs, see https://github.com/spion/adbfs-rootless/issues/59
1) I never use spaces myself (for that very reason), but I'm too lazy to rename files people sent me.
2) Will try! But setting up a Codeberg account is on my list of a while and not sure when I will get to it.
@floppy if 2) is already on your list, why not just do it? Takes maybe 5 min 😉
That is really true, at least as far as only the actual account creation is concerned.

But before that I wanted to settle on some kind of way of handling my online identities. For privacy reasons I want to keep different interests, stuff to be put online (so much), and social interactions deliberately dissociated. As for in this case, I haven't completely settled on e.g. a proper online name for the nerdier interests. ("floppy" is nice, but wasn't intended to be final. 🙂)
I haven't made it to Codeberg yet, so in the interest of not delaying it until I forget, I'll drop some thoughts here quickly. I hope that's ok. :)

In terms of documentation, I think it might be good for people less familiar with rsync to point out that in the config's .devices[].sync[].{devdir,pcdir} should keep the trailing slash. (Or some handling in the script might be nice.)
@floppy Sorry, but here those hints get lost. If you don't want to make an account at Codeberg, you can find my mail address in the imprint of my website 😉

And good point with the trailing slash – had that in mind but always forget…
I fully agree that other forms of communication work better for such topics, but it's a bit tricky for me right now-now. (Hopefully that changes again soon.)
I prefer to log to stdout only, which afaict is the unspecified option. If you think this might be interesting to others, this functionality could be documented explicitly. :) (Alternatively maybe logging to a file, but really these are just some pointers without acute need.)

I'm pretty swamped at the moment, so I might need a few more days, but I'll give adbsync a more thorough test and get back to you in a while!
@floppy log to stdout only: "logfile":"none" – and maybe 2>&1 if you really want to re-route errors there too. And yes, that is documented explicitly – see inside the doc/ dir 😉

Logging to a file: Sure, same thing and also documented: "logfile":"/path/to/logfile". Everything that's not just empty, "none" or "syslog" is expected to be a file name.
@floppy with the latest commit, adbsync makes sure devdir & pcdir have a trailing slash (if not it adds it), so docu must only point out it must be dirs (not a file name) – so it's your last wish I just implemented :awesome:

Further, no longer adjusting timestamps on push. Guess what I just discovered: "adb push" supports a `--sync` parameter only pushing newer files & taking care for timestamps. "adb pull" unfortunately does not support that or rsync+adbfs would only be needed for "--delete"…
I am not subscribed to many issues or projects, but incidentally I am for adbfs-rootless (for a long time actually) and incidentally I found your comments in my email inbox today. :)

Thank you for the update also! adb's parameter sounds like good news, at least partially. Maybe they fix the "pull" sub-command too some time.

Thanks for taking care of the trailing slashes! 😉 I think other people checking out the project will benefit greatly there. :)