AdbSync


AdbSync is a Win32 utility for syncing files to and from an Android device.

Usage: adbsync [flags] hostroot androidroot [altroot] /h update host /a update android /s search subdirectories /l list all files or d (differences), h (host only), a (android only) /i ignore files in pattern list /o only files in pattern list /d device name /v verbose /q quiet /0 one hour differences are considered same /1 use 1 second resolution (ext*, default) /2 use 2 second resolution (vfat) /h and /a use s (create subdirs), c (create files), u (update files), default=cu. Pattern lists are *? format, semicolon delimited.

Operation

AdbSync uses the stock ADB server daemon running on the Windows host. If you are making a batch file you probably want to start with adb start-server. If the ADB server is already running, this will have no effect.

AdbSync can update the host (Windows), the Android or both. The /h, /a, /s flags control the operation.

Is your device rooted?

To access all storage areas on your device the ADB running on your device must be rooted. There are three possible conditions: rooted, rootable, non-rootable. Only real rooted gives you access to all of storage like /data.

RootedC:\>adb shell #

RootableC:\>adb shell $ su #

Non-rootableC:\>adb shell $ su /system/bin/sh: su: inaccessible or not found $

Paths

The host paths are specified in Windows (backslash) format using the host current directory. The Android paths are specified in Linux (forward slash) format using the Android root directory. Don't start an Android path with a slash because it will be interpreted as a command flag (and it is unnecessary).

Working with the /sdcard directory

/sdcard on an Android is usually a link. With some Androids you may need to use actual paths with AdbSync (because the links are not followed). Often /sdcard will be the start of a series of links. Be sure to follow to the end. You can use ls -l or readlink.

A few examples:
/sdcard → /storage/emulated/legacy → /mnt/shell/emulated/0
/sdcard → /storage/self/primary → /mnt/user/0/primary → /storage/emulated/0

Filtering by File Name or Type

The /i flag will ignore selected files. Example: /i*.jpg;*.png means ignore JPEGs or PNGs.

The /o flag will only sync selected files. Example: /oreport?.pdf means only sync report1.pdf, report2.pdf...

Ignoring Directories

If a file with the name of ".noadbsync" is placed in a directory in either the host or Android, that directory will be ignored. That file can be of length zero.

Device Selection

The optional /d flag specifies which ADB device to use. Example: /d12345678

It's probably a good idea to specify this in batch files to prevent the wrong device from being updated.

Timestamp resolution

VFAT and DOS filesystems only have a file timestamp resolution of 2 seconds. When comparing timestamps from modern filesystems this may cause anomalies. The default of AdbSync is to use 2 second resolution. The /1 allows timestamp comparisons of 1 second. This should only be used when both the host and Android root filesystems are using 1 second resolution.

The /0 is a hack that considers timestamps that are different by exactly ±1 hour to be equivalent. It is used when daylight savings has affected all the timestamps on a VFAT filesystem to prevent everything from being updated.

Examples

Show usage:

C:\>adbsync /?

Copy photos to desktop (but see above about /sdcard):

C:\>adbsync /h C:\Photos\Nokia999 sdcard/DCIM/Camera

Copy music to Android:

C:\>adbsync /acsu /s "C:\My Music" sdcard/Music

Backup application data (requires real rooted):

C:\>adbsync /hcsu /s C:\Important\Frogger data/data/com.frogger

Synchronize in both directions text memos:

C:\>adbsync /h /a C:\Shopping sdcard/ToDo /o*.txt

Download the executable.