4
14
Fork
You've already forked adbsync
1
Synchronize your Android device with your Linux machine using rsync and adbfs
Shell 100%
Find a file
2023年03月08日 00:14:49 +01:00
doc add CLI options to disable/enable sync pairs for specific run 2023年02月26日 02:20:49 +01:00
.gitignore initial check-in of the "early bird" 2022年12月13日 22:51:47 +01:00
_adbsync add Bash auto-completion 2023年03月08日 00:14:49 +01:00
adbsync add CLI options to disable/enable sync pairs for specific run 2023年02月26日 02:20:49 +01:00
LICENSE initial check-in of the "early bird" 2022年12月13日 22:51:47 +01:00
README.md add Bash auto-completion 2023年03月08日 00:14:49 +01:00

adbsync

As I was tired of having umpteen separate apps on each device for rare tasks, and especially as I could not find a proper one for syncing with my own resources without setting up stuff on all ends, I decided to create myself this little tool.

adbsync requires no app counter-part on the Android device(s). On the Linux end it utilizes a few tools, which I already used for different other purposes, to achieve the goal of getting a few things synced between my Android device and my computer. You might not have them installed yet, so let me give you the list:

Requirements

  • Android's ADB tools. These can e.g. be installed via your distributions packaging system (android-tools-adb or simply adb), dragging in several dependencies – or by downloading my minimal package from here.
  • adbfs is used to mount your Android device via ADB, so it shows up in your computer's local file system. This is not only useful for adbsync but also makes it easy to access your device's files from your PC.
  • the jq binary to parse your JSON configuration. On Linux, it usually comes via your distribution's package repo as jq.
  • Developer options and USB Debugging enabled on your Android device.
  • an empty directory to mount your Android device to.
  • a JSON configuration file telling adbsync what to sync and how. An example JSON (plus one with some comments on it – JSON does not support comments) can be found in the doc/ sub-directory here in this very Git repo.

Instructions

For now just a few simple hints, I might add some more detailed instructions later:

  • prepare an empty directory to mount your Android device to.
  • copy the example doc/devices.json and edit the copy to your needs. You can then pass this "SPECFILE" (or "settings file") to adbsync via the -s command-line parameter; if not specified adbsync will look for for a devices.json first in the current working directory, if none found there then in $HOME/.config/adbsync/ – and complain loudly if it cannot find any.
  • run ./adbsync -h to get some simple help and see how to call the script. Optionally, place adbsync somewhere in your $PATH to have it accessible from everywhere.
  • consider performing your first runs in DRYRUN mode (pass the -d option to the script) to first get a feeling what the script will do. In this mode, no changes are perfomed – instead actions are logged to the screen, including the commands otherwise executed. If that looks fine to you, run adbsync without the -d option to have it really do its job.

Auto-Completion

For command auto-completion with Bash (might work with other shells as well but was not tested by me), you can source the included _adbsync file (see bash-completion for details). This would happen automatically if you place _adbsync into /etc/bash_completion.d and, according to the project documentation, should also work when placed into ~/.local/share/bash_completion.d/completions/. The latter did not work for me (with bash-completion v2.10), though; so I added the following to my ~/.bash_completion:

export BASH_COMPLETION_USER_DIR=$HOME/.local/share/bash_completion.d
for f in ${BASH_COMPLETION_USER_DIR}/completions/*; do
 [[ -f "$f" ]] && . "$f"
done

DISCLAIMER

Use this at your own risk. I will not be liable for any damages etc (see the license) and take or give no warranties – except that it will consume a little disk-space when checked out... That said, I'm using it here regularly with multiple devices and it's working fine for me.

LICENSE

As indicated by the included LICENSE file, this little script is protected by the GNU Public License GPLv2.