Skip to main content

Better version of adb-sync for Python3

Project description

⚡adbclone Hits

A rclone like program to copy files between a computer and an Android device

adbclone GIF

⚡Benefits:

adbclone offers significantly faster and more reliable file transfers for larger files compared to traditional MTP (Media Transfer Protocol)

⚡Installation:

Available on PyPI

pip install adbclone

⚡Usage:

To push from your computer to your phone use

adbclone --show-progress push LOCAL ANDROID

To pull from your phone to your computer use

adbclone --show-progress pull ANDROID LOCAL

Full help is available with $ adbclone --help

⚡Flags:

  • --show-progress Show progress of transferring files
  • --copy-to-new-folder updated files will be copied to a new folder to work on later and can be merged
  • --show-tree Show tree of source and destination
  • --del will delete files and folders on the destination end that are not present on the source end. This does not include exluded files.
  • --delete-excluded will delete excluded files and folders on the destination end.
  • --exclude can be used many times. Each should be a fnmatch pattern relative to the source. These patterns will be ignored unless --delete-excluded is specified.
  • --exclude-from can be used many times. Each should be a filename of a file containing fnmatch patterns relative to the source.

⚡ToDos:

  • Add Progress
  • Multiple Transfers
  • Add more ToDos

⚡Credits:

Previous Readme

Better ADB Sync

An rsync-like program to sync files between a computer and an Android device

Installation

Available on PyPI

$ pip install BetterADBSync

QRD

To push from your computer to your phone use

$ adbsync push LOCAL ANDROID

To pull from your phone to your computer use

$ adbsync pull ANDROID LOCAL

Full help is available with $ adbsync --help

Intro

This is a (pretty much from scratch) rewrite of Google's adbsync repo.

The reason for the rewrite is to

  1. Update the repo to Python 3 codestyle (strings are by default UTF-8, no more b"" and u"", classes don't need to inherit from object, 4 space indentation etc)
  2. Add in support for --exclude, --exclude-from, --del, --delete-excluded like rsync has (this required a complete rewrite of the diffing algorithm)

Additions

  • --del will delete files and folders on the destination end that are not present on the source end. This does not include exluded files.
  • --delete-excluded will delete excluded files and folders on the destination end.
  • --exclude can be used many times. Each should be a fnmatch pattern relative to the source. These patterns will be ignored unless --delete-excluded is specified.
  • --exclude-from can be used many times. Each should be a filename of a file containing fnmatch patterns relative to the source.

Possible future TODOs

I am satisfied with my code so far, however a few things could be added if they are ever needed

  • --backup and --backup-dir-local or --backup-dir-android to move outdated / to-delete files to another folder instead of deleting

---BEGIN ORIGINAL README.md---

adb-sync

adb-sync is a tool to synchronize files between a PC and an Android device using the ADB (Android Debug Bridge).

Related Projects

Before getting used to this, please review this list of projects that are somehow related to adb-sync and may fulfill your needs better:

  • rsync is a file synchronization tool for local (including FUSE) file systems or SSH connections. This can be used even with Android devices if rooted or using an app like SSHelper.
  • adbfs is a FUSE file system that uses adb to communicate to the device. Requires a rooted device, though.
  • adbfs-rootless is a fork of adbfs that requires no root on the device. Does not play very well with rsync.
  • go-mtpfs is a FUSE file system to connect to Android devices via MTP. Due to MTP's restrictions, only a certain set of file extensions is supported. To store unsupported files, just add .txt! Requires no USB debugging mode.

Setup

Android Side

First you need to enable USB debugging mode. This allows authorized computers (on Android before 4.4.3 all computers) to perform possibly dangerous operations on your device. If you do not accept this risk, do not proceed and try using go-mtpfs instead!

On your Android device:

  • Go to the Settings app.
  • If there is no "Developer Options" menu:
    • Select "About".
    • Tap "Build Number" seven times.
    • Go back.
  • Go to "Developer Options".
  • Enable "USB Debugging".

PC Side

  • Install the Android SDK (the stand-alone Android SDK "for an existing IDE" is sufficient). Alternatively, some Linux distributions come with a package named like "android-tools-adb" that contains the required tool.
  • Make sure "adb" is in your PATH. If you use a package from your Linux distribution, this should already be the case; if you used the SDK, you probably will have to add an entry to PATH in your ~/.profile file, log out and log back in.
  • git clone https://github.com/google/adb-sync
  • cd adb-sync
  • Copy or symlink the adb-sync script somewhere in your PATH. For example: cp adb-sync /usr/local/bin/

Usage

To get a full help, type:

adb-sync --help

To synchronize your music files from ~/Music to your device, type one of:

adb-sync ~/Music /sdcard
adb-sync ~/Music/ /sdcard/Music

To synchronize your music files from ~/Music to your device, deleting files you removed from your PC, type one of:

adb-sync --delete ~/Music /sdcard
adb-sync --delete ~/Music/ /sdcard/Music

To copy all downloads from your device to your PC, type:

adb-sync --reverse /sdcard/Download/ ~/Downloads

ADB Channel

This package also contains a separate tool called adb-channel, which is a convenience wrapper to connect a networking socket on the Android device to file descriptors on the PC side. It can even launch and shut down the given application automatically!

It is best used as a ProxyCommand for SSH (install SSHelper first) using a configuration like:

Host sshelper
Port 2222
ProxyCommand adb-channel tcp:%p com.arachnoid.sshelper/.SSHelperActivity 1

After adding this to ~/.ssh/config, run ssh-copy-id sshelper.

Congratulations! You can now use rsync, sshfs etc. to the host name sshelper.

Contributing

Patches to this project are very welcome.

Before sending a patch or pull request, we ask you to fill out one of the Contributor License Agreements:

Disclaimer

This is not an official Google product.

---END ORIGINAL README.md---


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adbclone-0.0.4.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

adbclone-0.0.4-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file adbclone-0.0.4.tar.gz.

File metadata

  • Download URL: adbclone-0.0.4.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.3

File hashes

Hashes for adbclone-0.0.4.tar.gz
Algorithm Hash digest
SHA256 43261b8f4e021589b2ff4c822e4dab4fecdf24c60e9e3e083eb7634baf7b7590
MD5 9f3799f2b9237a3e0d29ab34dcad7829
BLAKE2b-256 a7d6043806b0700eeb87b64ac7d61892be656bf94173a655ae9f6c3fff00ab42

See more details on using hashes here.

File details

Details for the file adbclone-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: adbclone-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.3

File hashes

Hashes for adbclone-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6c4908d9f39c0ab488d9dd52c4cdb0a2dc85b3907f53382c448bd8fc88aa93ef
MD5 29b8818f79e29edeb3b27336cd85d991
BLAKE2b-256 e5181e66f4a9b03a70c30d8f490a3a67b463dc3d93d76a3ff9cac00b34be7b1a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page