Odrive Sync Agent: A CLI/scriptable interface for odrive's Progressive Sync Engine for Linux, OS X, and Windows

Linux/MacOS bash-based:


This uses find to recurse and sync. The output is not ideal, though, since it is all queued up. You would need to change the path from ~/odrive-agent-mount/Dropbox/ to whatever you require, of course:

output="go"; while [ "$output" ]; do output=$(find "$HOME/odrive-agent-mount/Dropbox/" -name "*.cloud*" -exec python "$HOME/.odrive-agent/bin/odrive.py" sync "{}" \;); echo $output; done


This second one uses an extra file descriptor trick to push the output out in realtime. Again, you will need to change the path:

exec 6>&1;output="go"; while [ "$output" ]; do output=$(find "$HOME/odrive-agent-mount/Dropbox/" -name "*.cloud*" -exec python "$HOME/.odrive-agent/bin/odrive.py" sync "{}" \;|tee /dev/fd/6); done

If you only wanted to sync the files immediately inside the specified folder:
exec 6>&1;output="go"; while [ "$output" ]; do output=$(find "$HOME/odrive-agent-mount/Dropbox/" -maxdepth 1 -name "*.cloud" -exec python "$HOME/.odrive-agent/bin/odrive.py" sync "{}" \;|tee /dev/fd/6); done


Adding parallelization to the mix with xargs, contributed by @stuckj. num_procs = max # of parallel processes (set to 4 in the example):
exec 6>&1;num_procs=4;output="go"; while [ "$output" ]; do output=$(find "$HOME/odrive-agent-mount/Dropbox/" -name "*.cloud*" -print0 | xargs -0 -n 1 -P $num_procs "$HOME/.odrive-agent/bin/odrive.py" sync | tee /dev/fd/6); done

Dynamically adjust parallel processing “pool” using SIGUSR1(10) and SIGUSR2(12), contributed by @paradox606:
Decrease parallelism by 1 (down to 1 process): kill -12 $(pidof xargs)
Increase parallelism by 1 (up to max specified in xargs -P): kill -10 $(pidof xargs)


Windows Batch:

Batch via @bojandjuric:

Place into a .bat file

@echo off cd /d %~dp0 set FOLDERPATH="Folder path to sync here" set ODRIVEBIN="odrive cli binary client path here" for /r "%FOLDERPATH%" %%i in (*.cloudf) do "%ODRIVEBIN%" sync "%%i" for /r "%FOLDERPATH%" %%i in (*.cloud) do "%ODRIVEBIN%" sync "%%i"


Windows Powershell
One-liner script (run via a standard command prompt):

powershell -command "& {$syncpath=\"Folder path to sync here\";$syncbin=\"odrive cli binary client path here\";while ((Get-ChildItem $syncpath -Filter \"*.cloud*\" -Recurse | Measure-Object).Count){Get-ChildItem -Path \"$syncpath\" -Filter \"*.cloud*\" -Recurse | % {echo \"Syncing: $($_.FullName)n";& “$syncbin” “sync” “$($_.FullName)”;}}}"`


Python:
I forked the official odrive CLI and added recursive sync here:

1 Like