Sync to odrive on Linux (CLI)

linux
sync-to-odrive

#1

So on my Mac or windows machines, I have the ability to sync any folder on my system, not just in the oDrive tree, and then unsync it. All the instructions I’m seeing online for the Odrive sync agent show examples from the odrive-agent mounted directory, but in my case I have about a TB of pictures and home movies that I really don’t want to move around if I don’t have to. How can I tell the oDrive command line agent to sync this directory that is not already a .cloudf placeholder?


#2

Hi @toupeiro,
You can setup “sync to odrive” folders on Linux by creating additional mounts. The first mount you create with the odrive agent is the “default” odrive folder, but you can create additional mounts as long as you have a Premium subscription.

mount [local path] [remote odrive path]


#3

So to interpret that (because I’m trigger shy), thats odrive mount ~/AllMyPictures /MyCloudMountpoint and it will just start synchronizing it?

The layout would be something like

Local:
/folder1/pics
/folder2/pics
/folder3/vids
/folder4/etc/etc
(no .cloud or .cloudf files here yet)

Remote odrive:
/folder1/pics
/folder2/pics
folder4/etc/etc

In this scenario, would it be smart enough to leave the identical files alone (create .cloudf stubs) and only sync folder 3?


#4

#!/bin/bash
Here’s an example of what I’ve been doing so far to sync stuff in linux because I’ve been worried to mount in place for fear of trash canning either a lot of cloud pics OR a lot of local ones.

Set new line as the only break in find loops. (Good for spaces in filenames)

IFS=$’\n’
SOURCES=~"/All/my/pictures/and/videos/“
SYNCDIR=”~/datadisk/ODrive/“
CLOUDPATH=”/Amazon1"

SetComparisonTargets()
{
## Define the two locations to compare.

    ODriveFiles=$(ls -1 $SYNCDIR | sed -e 's/\.cloud\|\.cloudf//')
    PicFiles=$(ls -1 $SOURCES)
}

ActivateOdriveAgent()
{
nohup “$HOME/.odrive-agent/bin/odriveagent” > /dev/null 2>&1 &
sleep 2
}

MountOdriveDireTarget()
{
odrive mount $SOURCDIR $CLOUDPATH
sleep 2
}

DoComparison()
{
diff -u <(echo “$ODriveFiles”) <(echo “$PicFiles”) | grep ^+ | grep -v “/dev/fd” | cut -d + -f 2 > /tmp/differences
}
DoSync()
{
for i in $(cat /tmp/differences);
do rsync -av $SOURCES"$i" $SYNCDIR;
done
}

WaitForCompletion()
{
while [ $(odrive syncstate $SYNCDIR | head -n 1) = “Active” ]
do
odrive status --uploads
sleep 5
clear
done
}
UnsynctoCloud()
{
for j in $(cat /tmp/differences);
do odrive unsync $SYNCDIR"$j"
sleep 2
done
}
UnmountandStopOdriveAgent()
{
odrive unmount $SYNCDIR
sleep 1
odrive shutdown
sleep 1
}

Sequence the actions

ActivateOdriveAgent
MountOdriveDireTarget
SetComparisonTargets
DoComparison
DoSync
WaitForCompletion
UnsynctoCloud
UnmountandStopOdriveAgent


#5

Hi @toupeiro,

In this case it will compare both sides and determine what needs to be synced. In most cases that means that files that already exist on the remote side will be marked as syced without having to upload anything. Anything local that has not been uploaded yet, will be. Anything on the remote side that is not on the local side will show as a placeholder file.

I don’t see $SOURCDIR defined. Is that supposed to be odrive mount $SYNCDIR $CLOUDPATH?

In any case, with a “sync to odrive” folder (additional mount), you can forego the rsyncing between two folders and just sync the folder directly.


#6

Thanks Tony,

What you caught was a rename on the fly that I didn’t like and intended to rename also in the source script I copied it from :P.

I’ve been testing the way you described and so far it’s been working like a charm. only showing One file/directory as “not allowed” that I need to figure out.

Thanks so much for the continued great support! I really do enjoy Odrive and speak of it often with my colleagues. Really looking forward to B2 r/w and more one-way backup capabilities! Keep up the great work!


#7

Also, my wife (whom said pictures belong to) asked me to plug that a GUI companion to odrive on linux would be “awesome sauce”. :wink:


#8

Hi @toupeiro,

You can use the status --not_allowed command to see if there is additional information about that item.

Thanks for your patience and for being an odrive user!