Skip to content

Latest commit

 

History

History
97 lines (67 loc) · 2.91 KB

README.md

File metadata and controls

97 lines (67 loc) · 2.91 KB

adb-sync

Usage

Note: The supported Android version is Android 7.0 Nougat (API Version 24) and above, because it depends on ifaddrs which is supported officially only above this version.

Usage: adb-sync [OPTIONS] <ANDROID_DIR> <HOST_DIR>

Arguments:
  <ANDROID_DIR>
          Path of the source directory

  <HOST_DIR>
          Path of the destination directory

Options:
      --android-bin-search-path <ANDROID_BIN_SEARCH_PATH>
          Search `adb-sync-android` in this path. Default to where `adb-sync` locates
          
          [default: .]

      --no-stdio
          Do not fall back to the stdio method when Android IP is unavailable

      --no-tcp
          Use stdio only

      --skip-failed
          Skip indexing failure

      --android-ip <ANDROID_IP>
          Manually specify the Android IP instead of automatic detection.
          
          Only used in TCP mode.

  -h, --help
          Print help (see a summary with '-h')

Build

  • Set up Rust with NDK toolchain

    An example configuration file (replace these paths with yours):

    # <project>/.cargo/config
    
    [build]
    [target.aarch64-linux-android]
    linker = "/home/bczhc/bin/AndroidSdk/ndk-ln/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang"
    ar = "/home/bczhc/bin/AndroidSdk/ndk-ln/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
    
    [env]
    TARGET_CC = "/home/bczhc/bin/AndroidSdk/ndk-ln/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang"
    TARGET_AR = "/home/bczhc/bin/AndroidSdk/ndk-ln/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
  • Install Android targets using rustup:

    rustup target add aarch64-linux-android x86_64-unknown-linux-musl

    If your Android architecture is not aarch64, choose some others (also change $android_target in ./build-rust correspondingly):

    • aarch64-linux-android
    • armv7-linux-androideabi
    • i686-linux-android
    • x86_64-linux-android
  • Run ./build-rust

Run

After ./build-rust, run:

./adb-sync

Limitations and Notes

  • Relies on mtimes
  • No multiple files/directories and file exclusion support
  • Empty directories won't be synced
  • Only supports regular files (that's, totally ignores symlink, pipe etc.; no reflink or hard link awareness)

I've found project https://github.com/google/adb-sync and https://github.com/jb2170/better-adb-sync, but their sync speed is quite slow; can't fulfill my personal requirements :).

Script implementation

For the initial script implementation, see script-impl branch.

For syncing over network, see https://github.com/bczhc/FileSync