Linux (using cli): how to sync (and keep it synced) a selected folder and all its content

I’m hopping to get Google Drive in Ubuntu using Odrive to keep a couple of folders in sync (it would be selective sync, don’t want all my google drive content in the machine).

I manage to follow the cli odrive agent guide to get the folder I want to sync, but its content remain as placeholders. What is the command to get all files and folders within a sync folder to also sync?

Hi @mario,
Take a look here for one-liner examples to perform recursive sync: Odrive Sync Agent: A CLI/scriptable interface for odrive's Progressive Sync Engine for Linux, OS X, and Windows - #13 by Tony

You can also take a look at this post below:

Additionally, I forked the CLI and added recursive sync here: GitHub - amagliul/odrive-utilities: Utilities for odrive

Thank you Tony,

I managed using the first option for now but it looks like your custom cli tool looks more efficient.

How can I use it? just clone the repo and run “python odrivecli.py [command]”?

Also, how can I add binary odrive client to ubuntu path so that I don’t need to type the whole path to it everytime?

Hi @mario,
You only need the odrivecli.py file, so you can grab that individually if you want. The CLI recursive sync is single-threaded, though, so the one-liner is actually going to be more performant, if you are downloading lots of stuff.

For making typing easier you can setup an alias, like this:
echo "alias aliasname='command'" >> ~/.bash_aliases && source ~/.bash_aliases

So, for example:
echo "alias odrivecli='python $HOME/.odrive-agent/bin/odrive.py'" >> ~/.bash_aliases && source ~/.bash_aliases

Then you can just type odrivecli to run the CLI.

hi, i can’t understand what’s the utility of odrivecli.py. i’m on ubuntu 17

whit this comand:
"$HOME/.odrive-agent/bin/odrive" sync "$HOME/path-to-folder.cloudf"

i get same results of
odrivecli synch "$HOME/$HOME/path-of-folder.cloudf"

no recursion, i get only path-of-folder and not subfolder and files sycnrhonization. Where’s my mistake?

i also notice that on the bash script:
exec 6>&1;num_procs=10;output="go"; while [ "$output" ]; do output=$(find "$HOME/Cloud/path-to-folder/" -name "*.cloud*" -print0 | xargs -0 -n 1 -P $num_procs "$HOME/.odrive-agent/bin/odrive.py" sync | tee /dev/fd/6); done

i have to add “phyton”
exec 6>&1;num_procs=10;output="go"; while [ "$output" ]; do output=$(find "$HOME/path-to-folder/" -name "*.cloud*" -print0 | xargs -0 -n 1 -P $num_procs phyton "$HOME/.odrive-agent/bin/odrive.py" sync | tee /dev/fd/6); done

Hi @william.melatini,
The basic odrive CLI doesn’t offer recursion, but you can use a script like the one you have listed. The reason you needed to add ‘python’ to that, is because you are calling the python script instead of the binary script. You can use the binary version like this:

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

exec 6>&1;num_procs=5;output="go"; while [ "$output" ]; do output=$(find "$HOME/path-to-folder/" -name "*.cloud*" -print0 | xargs -0 -n 1 -P $num_procs "$HOME/.odrive-agent/bin/odrive" sync | tee /dev/fd/6); done

with your script recursion not works, i’m missing somethings?

With this comand:
odrivecli synch "$HOME/$HOME/path-of-folder.cloudf"
would i sync all files and sub folder?

with bush script all seem to works fine except for this notices at the end:
usage: odrive sync [-h] placeholderPath odrive sync: error: too few arguments

Hi @william.melatini,
odrivecli will not perform recursion on its own but the script can. Make sure the folder you want to recursively sync has been synced once so that you are performing this on an actual folder and not a placeholder. Since the command is using find to recurse through the structure, it needs to start with a real folder.

This is the command I use on my own system:
date; exec 6>&1;num_procs=4;output="go"; while [ "$output" ]; do output=$(find "[insert path of the folder you want to sync]" -name "*.cloud*" -print0 | xargs -0 -n 1 -P $num_procs "$HOME/.odrive-agent/bin/odrive" sync | tee /dev/fd/6); done; date

For [insert path of the folder you want to sync] replace that with the full path to the folder you want to sync. Again, make sure that folder is not still a placeholder (.cloudf). For example, if you wanted to sync all of the content in the folder /home/ubuntu/odrive/Amazon Cloud Drive.cloudf You would perform these steps:

  1. Run: "$HOME/.odrive-agent/bin/odrive" sync "/home/ubuntu/odrive/Amazon Cloud Drive.cloudf"
  2. Run: date; exec 6>&1;num_procs=4;output="go"; while [ "$output" ]; do output=$(find "/home/ubuntu/odrive/Amazon Cloud Drive" -name "*.cloud*" -print0 | xargs -0 -n 1 -P $num_procs "$HOME/.odrive-agent/bin/odrive" sync | tee /dev/fd/6); done; date
1 Like

I’m on Ubuntu and I need to download contents from Amazon Cloud Drive
I can use only Odrive CLI, the big question is how to do it?

I have thousands of directories there, so syncing everything by hands is not an option
need to be able to do something odrive download / /path/to/download

Is it possible?

Hi @ike,
Take a look at the above thread, starting here: