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

**URL:** <https://forum.odrive.com/t/odrive-sync-agent-a-cli-scriptable-interface-for-odrives-progressive-sync-engine-for-linux-os-x-and-windows/499>\
**Category:** General\
**Created:** [March 25, 2016, 11:02pm UTC](https://forum.odrive.com/t/odrive-sync-agent-a-cli-scriptable-interface-for-odrives-progressive-sync-engine-for-linux-os-x-and-windows/499 "2016-03-25T23:02:24Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Tony](https://forum.odrive.com/user_avatar/forum.odrive.com/tony/32/19_2.png) [@Tony](https://forum.odrive.com/u/Tony)\
**Post date:** [March 25, 2016, 11:02pm UTC](https://forum.odrive.com/t/odrive-sync-agent-a-cli-scriptable-interface-for-odrives-progressive-sync-engine-for-linux-os-x-and-windows/499/1 "2016-03-25T23:02:24Z")

</div>

_Documentation also available here: [Agent/CLI (Linux, MacOS, Win) - Odrive Docs](https://docs.odrive.com/docs/odrive-sync-agent)_

- [Overview](#overview)
- [Installing odrive Sync Agent](#install)
- [Windows](#wininst)
- [OS X](#osxinst)
- [Linux/RPi](#linuxinst)
- [odrive Sync Agent quick start guide](#quickstart)
- [Available commands](#commands)
- [Helpful tips](#tips)
- [Direct download links](#downloads)

# **Overview**

The odrive Sync Agent provides advanced users with a flexible, scriptable interface to odrive’s powerful Progressive Sync engine. Use it to bring cloud access to almost any environment.

The odrive Sync Agent can be used on Windows (7+), OS X (10.7+), Linux (glibc 2.11+), Raspberry Pi/ARMv6 (glibc 2.13+) operating systems.

####Sync Agent service (odriveagent/odriveagent.exe)  
This is the “engine” and runs persistently. It will react to filesystem and remote changes and listen for commands from the odrive CLI.

####odrive CLI ( odrive.py/odrive/odrive.exe )

This is the client interface to the Sync Agent server. The odrive CLI is used from the command-line or from shell scripts to control and enhance Sync Agent behavior. The client is written in python and can be extended and customized to add additional functionality and automation, as well.

# Installing odrive Sync Agent

###windows installation

Open up powershell and run the following command to download and install the odrive Sync Agent to .odrive-agent in your user home directory. This will download the odrive Agent service, the odrive Agent python client, and the odrive Agent binary client. _The command doesn’t give much feedback, so just give it some time_:

> $o=“$HOME\.odrive-agent\bin”;mkdir “$o” -FORCE;(New-Object System.Net.WebClient).DownloadFile(“[https://dl.odrive.com/odrive-py","$o\odrive.py](https://dl.odrive.com/odrive-py%22,%22$o%5Codrive.py)”);(New-Object System.Net.WebClient).DownloadFile(“[https://dl.odrive.com/odriveagent-win](https://dl.odrive.com/odriveagent-win)”, “$o\o.zip”);$shl=new-object -com shell.application; $shl.namespace(“$o”).copyhere($shl.namespace(“$o\o.zip”).items(),0x10);del “$o\o.zip”;(New-Object System.Net.WebClient).DownloadFile(“[https://dl.odrive.com/odrivecli-win](https://dl.odrive.com/odrivecli-win)”, “$o\oc.zip”);$shl=new-object -com shell.application; $shl.namespace(“$o”).copyhere($shl.namespace(“$o\oc.zip”).items(),0x10);del “$o\oc.zip”;

To run the odrive Sync Agent server in the background, use the following command in powershell:

> Start-Job { & “$HOME\.odrive-agent\bin\odriveagent.exe” }

Now the odrive Sync Agent server is running and you can use the odrive CLI to control it. For example, the following command will display the available client commands:

_Python client_

> & python “$HOME\.odrive-agent\bin\odrive.py” -h

_Binary client_

> & “$HOME\.odrive-agent\bin\odrive.exe” -h

The following command will show the current status of the odrive Sync Agent:

_Python client_

> & python “$HOME\.odrive-agent\bin\odrive.py” status

_Binary client_

> & “$HOME\.odrive-agent\bin\odrive.exe” status

###OS X installation

Run the following command in your terminal to download and install the odrive Sync Agent to ~/.odrive-agent. This will download the odrive Agent service, the odrive Agent python client, and the odrive Agent binary client.:

> od=“$HOME/.odrive-agent/bin” && curl -L “[https://dl.odrive.com/odrive-py](https://dl.odrive.com/odrive-py)” --create-dirs -o “$od/odrive.py” && curl -L “[https://dl.odrive.com/odriveagent-osx](https://dl.odrive.com/odriveagent-osx)” | tar -xvzf- -C “$od/” && curl -L “[https://dl.odrive.com/odrivecli-osx](https://dl.odrive.com/odrivecli-osx)” | tar -xvzf- -C “$od/”

To run the odrive Sync Agent server in the background, use the following command in your terminal:

> nohup “$HOME/.odrive-agent/bin/odriveagent.app/Contents/MacOS/odriveagent”\>/dev/null&

Now the odrive Sync Agent server is running and you can use the odrive CLI to control it. For example, the following command will display the available client commands:

_Python client_

> python “$HOME/.odrive-agent/bin/odrive.py” -h

_Binary client_

> “$HOME/.odrive-agent/bin/odrive” -h

The following command will show the current status of the odrive Sync Agent

_Python client_

> python “$HOME/odrive-agent/bin/odrive.py” status

_Binary client_

> “$HOME/.odrive-agent/bin/odrive” status

###linux/RPi installation

Run the following command in your terminal to download and install the odrive Sync Agent to ~/.odrive-agent. This will download the odrive Agent service, the odrive Agent python client, and the odrive Agent binary client.:

_32bit Linux_

> od=“$HOME/.odrive-agent/bin” && curl -L “[https://dl.odrive.com/odrive-py](https://dl.odrive.com/odrive-py)” --create-dirs -o “$od/odrive.py” && curl -L “[https://dl.odrive.com/odriveagent-lnx-32](https://dl.odrive.com/odriveagent-lnx-32)” | tar -xvzf- -C “$od/” && curl -L “[https://dl.odrive.com/odrivecli-lnx-32](https://dl.odrive.com/odrivecli-lnx-32)” | tar -xvzf- -C “$od/”

_64bit Linux_

> od=“$HOME/.odrive-agent/bin” && curl -L “[https://dl.odrive.com/odrive-py](https://dl.odrive.com/odrive-py)” --create-dirs -o “$od/odrive.py” && curl -L “[https://dl.odrive.com/odriveagent-lnx-64](https://dl.odrive.com/odriveagent-lnx-64)” | tar -xvzf- -C “$od/” && curl -L “[https://dl.odrive.com/odrivecli-lnx-64](https://dl.odrive.com/odrivecli-lnx-64)” | tar -xvzf- -C “$od/”

_RPi_

> od=“$HOME/.odrive-agent/bin” && curl -L “[https://dl.odrive.com/odrive-py](https://dl.odrive.com/odrive-py)” --create-dirs -o “$od/odrive.py” && curl -L “[https://dl.odrive.com/odriveagent-rpi](https://dl.odrive.com/odriveagent-rpi)” | tar -xvzf- -C “$od/” && curl -L “[https://dl.odrive.com/odrivecli-rpi](https://dl.odrive.com/odrivecli-rpi)” | tar -xvzf- -C “$od/”

To run the odrive Sync Agent server in the background, use the following command in your terminal:

> nohup “$HOME/.odrive-agent/bin/odriveagent”\>/dev/null&

Now the odrive Sync Agent server is running and you can use the odrive CLI to control it. For example, the following command will display the available client commands:  
_Python client_

> python “$HOME/.odrive-agent/bin/odrive.py” -h

_Binary client_

> “$HOME/.odrive-agent/bin/odrive” -h

The following command will show the current status of the odrive Sync Agent

_Python client_

> python “$HOME/odrive-agent/bin/odrive.py” status

_Binary client_

> “$HOME/.odrive-agent/bin/odrive” status

#odrive Sync Agent quick start guide  
Now that you have the odrive Sync Agent installed and running, it is time to start playing with it!

1. **Create an odrive account**  
If you don’t have an odrive account yet, you can get one here: [https://www.odrive.com](https://www.odrive.com)

2. **Create an auth key for odrive Agent**  
Once you have created an account/signed-in, navigate to [odrive | Sign in](https://www.odrive.com/account/authcodes) and click on “Create Auth Key” to create an auth key that you can then use to authenticate your odrive Sync Agent install.

3. **Authenticate odrive Sync Agent**

4. **Create an agent mount**  
This will mount the root of your odrive to the local folder “odrive-agent-mount”. Make sure the local folder exists before attempting to mount.  
**Do not use a local folder that is currently used/monitored by the odrive Desktop Client (if you are running both on the same system). Local paths for odrive Agent and odrive Desktop Client need to be separate**:

> mkdir “$HOME/odrive-agent-mount”

```
You can then mount and see your odrive links listed in ./odrive-agent-mount

>mount [local folder] [remote odrive folder]

_Python client_
>python "$HOME/.odrive-agent/bin/odrive.py" mount "$HOME/odrive-agent-mount" / 

_OS X/Linux/Rpi binary client_
 >"$HOME/.odrive-agent/bin/odrive" mount "$HOME/odrive-agent-mount" /

_Windows binary client_

>& "$HOME\\.odrive-agent\bin\odrive.exe" mount "$HOME\odrive-agent-mount" /

```

1. **Sync an odrive folder**

2. **Sync a file**

# **Available commands**

> authenticate - authenticate odrive with an auth key  
> mount - mount remote odrive path to a local folder  
> unmount - remove a mount  
> sync - sync a placeholder  
> stream - stream a placeholder eg. stream path | appExecutable -  
> refresh - refresh a folder  
> unsync - unsync a file or a folder  
> syncstate - get sync status info (blue text is Synced, Pink is Active)  
> status - get status info  
> deauthorize - deauthorize odrive to unlink the current user and exit  
> empty trash - empty odrive trash  
> shutdown - shutdown odrive

> status also has the following flags for details:  
> –mounts get status on mounts  
> –sync\_requests get status on sync requests  
> –uploads get status on uploads  
> –downloads get status on downloads  
> –background get status on background requests  
> –trash get status of trash items  
> –waiting get status of waiting items  
> –not\_allowed get status of not allowed items

# **Helpful tips**  
**Detailed help**  
You can get more detailed help on individual commands. For example:

> authenticate -h

**Watch realtime status**

_Windows_

> while(1){& “$HOME\.odrive-agent\bin\odrive.exe” status;start-sleep -seconds 1}

_OS X/Linux/RPi_

> while true; do “$HOME/.odrive-agent/bin/odrive” status; sleep 1; done

**Logs**  
An odrive Sync Agent log file is located at “$HOME/.odrive-agent/log/agent.log”

**Streaming**  
To stream a file, use standard piping commands such as:

> “$HOME/.odrive-agent/bin/odrive” stream “placeholderPath” | “playerExecutablePath” -

_On windows this works in cmd.exe, but not in powershell_

**Recursive Sync**

> [@Odrive Sync Agent: A CLI/scriptable interface for odrive's Progressive Sync Engine for Linux, OS X, and Windows](https://forum.odrive.com/t/odrive-sync-agent-beta-a-cli-scriptable-interface-for-odrives-progressive-sync-engine-for-linux-os-x-and-windows/499/13):
>
> 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 realt…

**Copy, Sync, Unsync Automation**

> [@Odrive Sync Agent: A CLI/scriptable interface for odrive's Progressive Sync Engine for Linux, OS X, and Windows](https://forum.odrive.com/t/odrive-sync-agent-beta-a-cli-scriptable-interface-for-odrives-progressive-sync-engine-for-linux-os-x-and-windows/499/26):
>
> For your backup and unsync use case, you can script something like this in bash: #!/bin/bash agentdir="$HOME/.odrive-agent/bin" export agentdir agentmount="$HOME/odrive/Dropbox (Personal)" targetdir="$agentmount/temp" sourcedir="$HOME/Downloads/test\_directory" python "$agentdir/odrive.py" sync "$targetdir.cloudf" cp -R "$sourcedir" "$targetdir/" python "$agentdir/odrive.py" refresh "$targetdir" echo Waiting for odrive to start syncing $targetdir ... while [ "$(python "$agentdir/odrive.py" syncs…

# **Direct download links**  
_ **If you use the install instructions above you will get these versions** _  
: [Agent/CLI (Linux, MacOS, Win) - Odrive Docs](https://docs.odrive.com/docs/odrive-sync-agent#section--download-sync-agent-)

---

_[View the full topic](https://forum.odrive.com/t/odrive-sync-agent-a-cli-scriptable-interface-for-odrives-progressive-sync-engine-for-linux-os-x-and-windows/499)._
