adbsync.exe - Win32 command line syncer

Search This thread

Renate

Recognized Contributor / Inactive Recognized Dev
Well, how about this?

I cleaned up the code so that it will indicate directories that are not matched.
It still won't poke its nose down directories when it need not.

Code:
E:\Handy\New>adbsync /ld /v E:\Handy\ mnt/sdcard/DCIM/Camera

H                2013-09-17 00:53  Bogus
H             9  2013-09-17 01:43  Goodbye
H             7  2013-09-17 01:43  Hello

H   Host dir only               1
    Files match                68
H   Host file only              2
/l (with nothing) will list everything, in this case 71 lines.
Download in the signature.
 
  • Like
Reactions: osm0sis

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,767
40,432
Halifax
GT-i9250
Google Nexus 4
Works absolutely perfectly! Thank you so much for your efforts! :)

I'm selecting out the host only files and removing them with a batch script now :D:
Code:
[PLAIN]echo Removing old files . . .
type backup.log | bin\grep -E ^H" " | bin\cut -c 36- | bin\cut --delimiter=+ --fields=1 > host.log
echo ..\host.log >> host.log
for /f "delims=" %%f in ('type host.log') do @bin\rm -R "sdcard/%%f"
echo.

echo Cleaning up empty directories . . .
for /f "delims=" %%d in ('dir /s /b /ad ^| sort /r') do @rd "%%d" > nul 2>&1
echo.[/PLAIN]

Would it be alright if I put out a zip of my batch automation for your utility? It's got a customizable mountPoint, ignorePattern and onlyPattern variables, as well as a parsed ini file for long paths/filenames to ignore and zip up instead of having adbsync try to pull the files and halt. :good:

Edit: Renate NST gave permission via PM so ADBsync sdcard Backup v1.0 is now available in my Odds and Ends thread, if anyone is interested in a one-click automated backup solution. :)
 
Last edited:

roustabout

Senior Member
Feb 12, 2011
825
212
thanks so much for this. I wound up in a situation where I had no recent backups, couldn't get the gui to load, couldn't get my sdcard to mount - but had ADB available. Flashing a ROM was failing to get farther than that, so to have any chance I was going to have to nuke the device.

I was able to use adbsync to pull a lot of /data/data with great success. (I really only needed the information a single app was keeping but it's nice to have been able to pull so much more in case I think 'ooh! but...!' in a few weeks.)

and lo - a complete partition wipe and my device reanimated. After which I was able to restore the database for the app that had a few months' data in it, and it worked out fine.
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,767
40,432
Halifax
GT-i9250
Google Nexus 4
@Renate NST

Hey! Hope things are well. I've been wondering, will adbsync prefer the larger file if one is found on each end with the same timestamp? I'm thinking along the lines of adb/USB issues causing broken transfers and hoping adbsync will replace the partially downloaded files with the complete ones.

Edit: Actually it looks like an interrupted transfer results in a smaller Host file with a newer timestamp. Any way you can think of to accommodate that use case so it can resume and complete the A->H sync?
 
Last edited:

Renate

Recognized Contributor / Inactive Recognized Dev
Hmm, with writing to Android devices there could be an issue if the transfer were interrupted.
If the connection were the problem adbsync could be clever enough to retry.
If adbsync were interrupted somehow (^C should not break files) then the knowledge of the interrupted file would be lost.

In the other direction, to the host, adbsync could be changed to write temp files and only delete the old file and rename upon safe completion.

I've never had any of this happen to me.
If it did, I'd just delete the offending file and re-sync.
 
  • Like
Reactions: osm0sis

JVital2013

Member
Jul 19, 2012
40
21
Manheim, PA
Thanks for this great utility, it works great for me!

Are you planning on incorporating the ability to delete files from the target that were deleted from the source when you're only syncing one way? For example, if I manually delete somefile.foo on my computer and I use the /a flag with adbsync, I want it to delete somefile.foo from my phone as well.
 

JVital2013

Member
Jul 19, 2012
40
21
Manheim, PA
Sorry, the adbd daemon on Android devices does not support any mechanism for file deletion in the file sync service.

I'd have to open a separate shell service on adbd to delete files.
I may get around to implementing that.

That would be awesome :D. Right now I'm using the program to sync my music with iTunes and it works really well, but if I delete a song from iTunes I need to manually delete song from my phone. Not a big deal, but it would be a nice feature to automate it.

Also, are you planning on making the software open source at any point?
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,767
40,432
Halifax
GT-i9250
Google Nexus 4
Here's an interesting issue. Fails every time it hits this file:

Code:
<-            0  2014-07-05 18:03  0/multirom/roms/LPV79/data/app/sensor_ctl_socket -
Error "No such device or address" from ADB

And again with:
Code:
<-            0  2014-06-30 18:11  0/multirom/roms/LPV79/data/cam_socket1 -
Error "No such device or address" from ADB

Edit: Here's the complete list of what I had to ignore: sensor_ctl_socket;cam_socket*;wpa_ctrl_597-*;ndebugsocket

Anyway just seems like something adbsync might want to detect to prevent failures. :good:
 
Last edited:

demlv

Senior Member
Sep 16, 2008
552
231
Las Vegas, NV
I keep getting "heap commit failed" errors. No idea how to pull a log, but I'd be happy to try with some guidance.

Sent from my Galaxy Nexus using Tapatalk
 

demlv

Senior Member
Sep 16, 2008
552
231
Las Vegas, NV
About how many files are in the tree that you are syncing?

Thousands....the entire contents of my virtual SD card. This worked previously.

The 'pull' doesn't all get stored in memory before being written to disk/flash/storage does it?

Anticipating possible question here: PC w/ 8gb memory running Windows 7 and virtual memory enabled.
 

demlv

Senior Member
Sep 16, 2008
552
231
Las Vegas, NV
I figured as much.
I store the tree, not the contents.
Could you tell me how many thousands?

Here goes -- to be clear, I am using adbsync as implemented in osm0sis' "ADBsync sdcard backup" script which is built on top of your utility. Link to thread here: http://xdaforums.com/showthread.php?t=2239421

According to FX File Explorer on my phone, the virtual SD card that I am trying to pull presently holds 32,250 files in 5002 folders totaling 13.9gb of space. About 24,600 of the files form part of clockworkmod recovery dedupe-style nandroid phone backups, so each file seems to carry the name of its calculated hash -- every one of those 24,000+ files has a name that is about 60 characters long.

For what it's worth, I have a backup on my PC (from when this all worked perfectly a few months ago) and according to the PC that backup consists of 72,179 files in 4,749 folders occupying 24.9gb -- with even more of the CWM nandroid backup files with the same type of long names.
 

demlv

Senior Member
Sep 16, 2008
552
231
Las Vegas, NV
I double checked that everything was working correctly.
I have to look at the old version (September 16, 2013) to see if there was a problem.
Load the current adbsync.exe from the signature.

Note: This does not fix the issue that @osm0sis brought up a few posts earlier.

I just confirmed that the version supplied by osm0sis in his .zip has a different file size. I will use the newest version linked in your signature as soon as I have a chance and will report back. Thanks for troubleshooting my issue. :good:
 

Renate

Recognized Contributor / Inactive Recognized Dev
I meant that the version packed in that zip was from September 16, 2013.
(I looked at it already.)

I always put the Build Date in my Windows executables.
You can see that under "Properties" in Windows (File) Explorer.

Unrelated, my Win32 utility apkstamp.exe (in the signature) will tell you when an APK was compiled vs. when it was downloaded.
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,767
40,432
Halifax
GT-i9250
Google Nexus 4
Could you do this and paste it?
Code:
# busybox stat [i]nastyfile[/i] -c '%f %F'

I double checked that everything was working correctly.
I have to look at the old version (September 16, 2013) to see if there was a problem.
Load the current adbsync.exe from the signature.

Note: This does not fix the issue that @osm0sis brought up a few posts earlier.

The busybox in TWRP isn't accepting the -c option for stat, but here's the output of -f and without any args:
Code:
  File: "sensor_ctl_socket"
    ID: d3609fe804970d6b Namelen: 255     Type: ext2/ext3
Block size: 4096      
Blocks: Total: 6924146    Free: 4320206    Available: 4320206
Inodes: Total: 1761280    Free: 1713300
  File: 'sensor_ctl_socket'
  Size: 0         	Blocks: 0          IO Block: 4096   socket
Device: b31eh/45854d	Inode: 1671176     Links: 1    
Access: (0766/srwxrw-rw-)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-07-05 15:03:00.000000000
Modify: 2014-07-05 15:03:00.000000000
Change: 2014-07-05 15:03:00.000000000

Thanks for looking into it. :)

Edit: Booted into the device, the ROM busybox reports "c1f6 socket", the cam sockets are both c1f8, c1c0 for /data/system/ndebugsocket, and c1b0 for wpa_ctrl_* in /data/misc/wifi/sockets/
 
Last edited:
  • Like
Reactions: Renate

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,767
40,432
Halifax
GT-i9250
Google Nexus 4
Thanks for the info about Unix sockets, @osm0sis

Download the new version in the signature.
@Renate NST Thought of another small request.. ;)

Could adbsync automatically substitute _ for filename characters that are acceptable on Linux but not Windows? I'm mainly seeing this with photos I take with Hangouts for MMS being saved with :'s as <whatever>:nopm:.jpg. Thanks for the ongoing work! This tool is indispensable. :)
 
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...