adbsync.exe - Win32 command line syncer

Search This thread

Renate

Recognized Contributor / Inactive Recognized Dev
Because of the incredible success of my adbsync.exe on the Nook Touch (19 downloads! :p )
I've decided to advertise it to the general Android public.

There are all sorts of GUI file managers that serve as a front end to ADB.
(Some of them appear to use shelling to ADB instead of using port 5037.)
I wanted a command line program for Win32 that could sync my devices before I go out the door.
It had to work with a Nook Touch (2.1) connected on WiFi and a Kyocera Rise (4.0) connected on USB, often at the same time.

As any program with "option-itis", it runs into an alphabet soup of arguments.
The good part is that you mostly just have to get it right once and stick it in a batch or makefile.
There are options for recursive and whether to create missing subdirs or files.
It can copy in either or both direction and even a 3rd destination for resolving discrepancies.
Code:
usage:  adbsync [flags] hostroot androidroot [altroot]

/d  device name
/h  update host
/a  update android
/s  search subdirectories
/l  list files: d (differences), h (host only), a (android only)
/i  ignore files in pattern list
/o  only files in pattern list
/v  verbose
/q  quiet
/1  use 1 second resolution (ext*)
/2  use 2 second resolution (vfat)
Examples:
Code:
[color=red]Update android[/color]
adbsync C:\Books "sdcard/My Files/Books" /a /v

[color=red]Sync both directions[/color]
adbsync C:\Notes sdcard/Notes /a /h /v

[color=red]Sync both directions but don't overwrite the PC, use another dir[/color]
adbsync C:\Notes sdcard/Notes C:\Fixme /a /h /v

[color=red]Sync both directions including subdirectories[/color]
adbsync C:\Stuff sdcard/Stuff /a /h /s /v

[color=red]Sync only existing files on android[/color]
adbsync C:\Reference sdcard/Reference /au /s /v

[color=red]Update host with photos shot on handy (specifying device by id)[/color]
adbsync /d7a12820e /h C:\Handy\Photos sdcard/DCIM/Camera

[color=red]Update android with photos, but not vacation ones[/color]
adbsync C:\Photos sdcard/Photos /o*.jpg;*.jpeg /ivacation* /a /v
Note: For many systems sdcard is just a link (which adbsync.exe will not follow).
Use mnt/sdcard

Download in the signature.
 
Last edited:

E:V:A

Inactive Recognized Developer
Dec 6, 2011
1,447
2,222
-∇ϕ
Looks nice, but the problem is that it is hard to determine whether or not it is useful...since it is not clear what it is doing. What do you mean when you say "sync"? Perhaps give an example when you need this and a screen shot or two...
 

Renate

Recognized Contributor / Inactive Recognized Dev

Thanks for the bump! :victory:

adbsync.exe compares the timestamps on files on the host and android.
If the flags allow it, it will copy the newer file over the older one.
If the alternate root is specified and it would have overwritten the host's older file it will instead write to that directory.

The post above gives lots of examples.
If files are copied over, they will be listed.
if the /v (verbose) flag is specified, it will list statistics.
 
  • Like
Reactions: osm0sis

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,773
40,453
Halifax
GT-i9250
Google Nexus 4
This is an indispensable utility for Windows users wanting a complete snapshot of their device + sdcard with their backups. And a great time saver versus standard adb pull. Highly recommended!

Glad to see this over in the main Android Development and Hacking section finally. :)
 
Last edited:
  • Like
Reactions: adeii

Renate

Recognized Contributor / Inactive Recognized Dev
I've updated this a bit to correct for a few bugs.

There were a few anomalies if you tried to use the root of Android or the root of a Windows disk.

It will not try to copy links anymore.

If there is a permission problem with reading on the Android it will say so.

I should get around to adding options for ignoring errors, right now it stops.

Finally on your device /sdcard may be only a link.
Use the appropriate real path, probably /mnt/sdcard

Download in signature.
 

mejack03

Senior Member
Nov 8, 2010
189
22
Chennai
Not copying

I have empty folder in my PC named sdcard and i want to copy all my phone sdcard content to this folder. I used below comment but its not copying anything it just tells "A Android Dir only 33"

can you tell me what i am doing wrong?

adbsync /h /s /v "c:\Name\Name\Soft\Mobile_Soft\Nexus\sdcard\" "/mnt/shell/emulated/0"
 

Pkt_Lnt

Inactive Recognized Contributor
Dec 26, 2011
7,894
5,804
SLO
I am trying to ignore an entire directory. I have tried /i/Dir /iDir* /i/Dir/* and all continue to copy files from the directory. I am using the example above:

adbsync /hscu /s /v /iDir "e:\Nexus\sdcard\" "/mnt/shell/emulated/0"
 

Pkt_Lnt

Inactive Recognized Contributor
Dec 26, 2011
7,894
5,804
SLO
Thank you. It would be nice if a directory could be disabled. The one I have puts cache items with file names over 100 characters, and neither my win computer nor various cloud storage will take them. Wish I could still run linux, but alas, work software I need is win only.
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,773
40,453
Halifax
GT-i9250
Google Nexus 4
I'm still seeing issues with the following command putting stuff in the root of the working drive:

Code:
adbsync /hscu /s /ld /v "C:\ADBsync\sdcard\" "/data/media" /i*catalog*

I end up with a bunch of stuff in C:\data\media\ but not everything. So bizarre. I've tried adding/removing trailing slashes from both paths, and all sorts of stuff.

Edit: Seems to be an issue syncing 0 length files (like .nomedia) as well. Not seeing them get created/updated anywhere on the host side, even though adbsync logs report they are.
 
Last edited:

Renate

Recognized Contributor / Inactive Recognized Dev
Yes, the last version would not write zero length files.
That was a by-product of waiting for valid data before creating the file.

The new version (in the signature) addresses that.

For those that wanted ignoration :cyclops: of directories:
I left the current /i /o flags the way they were, that is, operating only on file names.

In the new version if you want a directory ignored, drop a file called .noadbsync in it.
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,773
40,453
Halifax
GT-i9250
Google Nexus 4
Yes, the last version would not write zero length files.
That was a by-product of waiting for valid data before creating the file.

The new version (in the signature) addresses that.

For those that wanted ignoration :cyclops: of directories:
I left the current /i /o flags the way they were, that is, operating only on file names.

In the new version if you want a directory ignored, drop a file called .noadbsync in it.

Great idea! This new version is still pulling files to my C:\ though (as reported a few times previously). :(

Any ideas for that issue?
 

Renate

Recognized Contributor / Inactive Recognized Dev
Great idea! This new version is still pulling files to my C:\ though (as reported a few times previously). :(

Any ideas for that issue?

Sorry, I've never seen this.
How many files does it do this to?
Are the filenames weird? Are the paths on the Android weird? Are the paths on the PC weird?
Does it say that it copied them?
Does the correct copy appear also?

I just did a sync like this with a few GB and didn't see anything wrong.
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,773
40,453
Halifax
GT-i9250
Google Nexus 4
Sorry, I've never seen this.
How many files does it do this to?
Are the filenames weird? Are the paths on the Android weird? Are the paths on the PC weird?
Does it say that it copied them?
Does the correct copy appear also?

I just did a sync like this with a few GB and didn't see anything wrong.

I wouldn't consider C:\ADBsync\sdcard to be a weird path, nor are /data/media/0/ paths particularly weird, especially when booted into CWM recovery like I am (ie. no weird FUSE FS stuff going on, and no symlinks involved). It copies a lot of files, but not all of them. I'll PM you a dir /s of my sdcard directory before and after the sync, a dir /s of the files that show up at C:\data\media and a log of adbsync's output.

This bug fixed and having an option to delete files that are host-only (to make adbsync clean up after itself) are the only 2 things I feel are missing in adbsync. :)
 

Renate

Recognized Contributor / Inactive Recognized Dev
Oops. :eek:

Yes, there was a problem copying updated Android files that existed on the host to the wrong directory.
That bug popped up in a restructuring of the code.

There is also an improvement for prompter error reporting when attempting to write to Android read-only or protected directories.

Download the new version in the signature.
 
  • Like
Reactions: osm0sis

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,773
40,453
Halifax
GT-i9250
Google Nexus 4
Oops. :eek:

Yes, there was a problem copying updated Android files that existed on the host to the wrong directory.
That bug popped up in a restructuring of the code.

There is also an improvement for prompter error reporting when attempting to write to Android read-only or protected directories.

Download the new version in the signature.

Confirmed squashed! :D

Seeing another issue now. adbsync is ignoring some files it shouldn't on the host side. I have a backup in my C:\ADBsync\sdcard\clockworkmod\backup\ directory that isn't in /data/media/clockworkmod/backup/ and adbsync isn't showing it in the log.

The command is still:
Code:
adbsync /hscu /s /ld /v "C:\ADBsync\sdcard\" "/data/media" /i*catalog*

So that should include everything. It pulls new backups from the Android side directory just fine, but it seems to ignore the old ones in the host directory.
 
Last edited:

Renate

Recognized Contributor / Inactive Recognized Dev
You're not syncing from the host to the android.
In this case when adbsync comes across directories on the host that are not on the android it does not even bother enumerating them.
We don't want to waste time traversing everything if we are not going to do anything with it anyway.

If you do want to cover everything in both directions, add /ascu
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,773
40,453
Halifax
GT-i9250
Google Nexus 4
Hmm. I see your point. However, I don't want to sync in both directions, just have it log what's missing. If there was a proper list only option then that'd be doable with my workaround to delete removed files from the host side (ie. a true host-side sync).

Edit: I know that /ld without /a or /h will list only, but it still doesn't list every host-only difference, like those directories. Could you please make list more thorough and traverse everything, or at least add an option for this?

/ldt maybe?
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 20
    Because of the incredible success of my adbsync.exe on the Nook Touch (19 downloads! :p )
    I've decided to advertise it to the general Android public.

    There are all sorts of GUI file managers that serve as a front end to ADB.
    (Some of them appear to use shelling to ADB instead of using port 5037.)
    I wanted a command line program for Win32 that could sync my devices before I go out the door.
    It had to work with a Nook Touch (2.1) connected on WiFi and a Kyocera Rise (4.0) connected on USB, often at the same time.

    As any program with "option-itis", it runs into an alphabet soup of arguments.
    The good part is that you mostly just have to get it right once and stick it in a batch or makefile.
    There are options for recursive and whether to create missing subdirs or files.
    It can copy in either or both direction and even a 3rd destination for resolving discrepancies.
    Code:
    usage:  adbsync [flags] hostroot androidroot [altroot]
    
    /d  device name
    /h  update host
    /a  update android
    /s  search subdirectories
    /l  list files: d (differences), h (host only), a (android only)
    /i  ignore files in pattern list
    /o  only files in pattern list
    /v  verbose
    /q  quiet
    /1  use 1 second resolution (ext*)
    /2  use 2 second resolution (vfat)
    Examples:
    Code:
    [color=red]Update android[/color]
    adbsync C:\Books "sdcard/My Files/Books" /a /v
    
    [color=red]Sync both directions[/color]
    adbsync C:\Notes sdcard/Notes /a /h /v
    
    [color=red]Sync both directions but don't overwrite the PC, use another dir[/color]
    adbsync C:\Notes sdcard/Notes C:\Fixme /a /h /v
    
    [color=red]Sync both directions including subdirectories[/color]
    adbsync C:\Stuff sdcard/Stuff /a /h /s /v
    
    [color=red]Sync only existing files on android[/color]
    adbsync C:\Reference sdcard/Reference /au /s /v
    
    [color=red]Update host with photos shot on handy (specifying device by id)[/color]
    adbsync /d7a12820e /h C:\Handy\Photos sdcard/DCIM/Camera
    
    [color=red]Update android with photos, but not vacation ones[/color]
    adbsync C:\Photos sdcard/Photos /o*.jpg;*.jpeg /ivacation* /a /v
    Note: For many systems sdcard is just a link (which adbsync.exe will not follow).
    Use mnt/sdcard

    Download in the signature.
    3
    A user suggested that I just compare the times in UTC.

    The adbd daemon delivers to adb and then to adbsync the file times already in UTC in 32 bit integer, Unix epoch, one second resolution.
    I get the host file times in UTC 64 bit Windows FILETIME format with 100 nanosecond resolution.
    Converting the Unix time to Windows FILETIME is simply a matter of adding 134774 (days between 1601 and 1970) x 86400 (seconds in a day) and multiplying by 10,000,000.
    That process is straight forward and has nothing to do with timezones or daylight savings.

    The problem is that Windows (and Unix by copying the same strategy) converts stored local times in files to UTC using the current daylight savings time offset.
    This means that the numbers I get from Android shift in spring and fall.

    The best solution is not to have anything to do with a filesystem that doesn't store file times in UTC.
    The only reason to use FAT volumes is to be able to mount them directly with USB UMS.
    That's a dubious advantage these days.
    3
    Yes, the last version would not write zero length files.
    That was a by-product of waiting for valid data before creating the file.

    The new version (in the signature) addresses that.

    For those that wanted ignoration :cyclops: of directories:
    I left the current /i /o flags the way they were, that is, operating only on file names.

    In the new version if you want a directory ignored, drop a file called .noadbsync in it.
    2
    I've updated this a bit to correct for a few bugs.

    There were a few anomalies if you tried to use the root of Android or the root of a Windows disk.

    It will not try to copy links anymore.

    If there is a permission problem with reading on the Android it will say so.

    I should get around to adding options for ignoring errors, right now it stops.

    Finally on your device /sdcard may be only a link.
    Use the appropriate real path, probably /mnt/sdcard

    Download in signature.
    2
    Yes, currently the include/only options operate on file names, not paths.

    I'll look into this...