HOWTO: Use rclone in Docker & sync shared OneDrive folders with your Synology

Cloud Sync cannot currently sync shared folders in personal OneDrive accounts. This is an issue for me because I have multiple family members whose documents I back up, and they share a read-only copy with my backup account.

I briefly messed around with a OneDrive container but didn't have a lot of success before I found out that rclone integrates with OneDrive.

TL;DR: Just use rclone.

This guide is mostly for people searching around looking for an answer to this problem. Since it's fresh in my mind, I thought I'd write it down.

Rclone can be installed locally, but this is at odds with my desire to Docker All The Things, which keeps the local installation to a minimum and makes it easily portable between systems. So for this guide, we'll be using the Docker image.

They have a basic guide on defining the Docker config for rclone which outlines the parameters. Below I have defined the volumes I want to mount, the user I want files created as, and the recommended parameters. Since this is the first time we're running it, I am passing the -i and -t switches so we get an interactive console, and passing the config command to rclone

sudo docker run -i -t --rm \
--volume /volume1/docker/rclone/config:/config/rclone \
--volume /volume1/storage/Sync:/data \
--volume /etc/passwd:/etc/passwd:ro --volume /etc/group:/etc/group:ro \
--user 1046:100 --device /dev/fuse \
rclone/rclone config

 

You're going to go through the new OneDrive setup with rclone. The config choices are straightforward. Note that, because we have no web browser available, we have to use the remote/headless machine setup. You'll need to have rclone installed on another machine for this, and you will copy and paste the token issued to your computer back into the Synology config. When it asks about "auto config" you must answer "no." Alternately, you can just run the rclone setup on another machine and copy the config file.

Here is the full Pastebin with some sections redacted for my setup.

If we check our config directory now, there should be an rclone.conf file there with your new remote config in it. To verify, run your non-interactive docker command (remove the -i and -t switches), but with the rclone command of lsd <remote name>:<bucket> - e.g. lsd onedrive: to list the directories in the remote:

sudo docker run --rm \
--volume /volume1/docker/rclone/config:/config/rclone \
--volume /volume1/storage/Sync:/data \
--volume /etc/passwd:/etc/passwd:ro --volume /etc/group:/etc/group:ro \
--user 1046:100 --device /dev/fuse \
rclone/rclone lsd onedrive:

 

Last step, synchronization. You just add the rclone sync command and you're done. I recommend running it with the --dry-run flag so that no permanent changes are made before you're sure everything is okay. In this case, it copies the contents of my "onedrive" remote into my /data/OneDrive folder.

sudo docker run --rm \
--volume /volume1/docker/rclone/config:/config/rclone \
--volume /volume1/storage/Sync:/data \
--volume /etc/passwd:/etc/passwd:ro --volume /etc/group:/etc/group:ro \
--user 1046:100 --device /dev/fuse \
rclone/rclone sync --progress --dry-run onedrive: /data/OneDrive

 

If this works, you can remove the --dry-run flag, and stick that command in your Task Scheduler to run on a schedule.

Hope someone finds this useful, either now or a future Google searcher seeking an answer. Until Synology gets their shit together and fixes Cloud Sync, anyway. I'm not a Docker expert, so suggestions or feedback are welcome!

Posted Apr 2, 2021, 2:17 AM UTC

34
ssps•

There is no need to use it in docker. It’s a go self contained executable without dependencies. Just copy it on the nas.

1
binaryvisionsOP•

I believe it has fuse as a dependency, does it not?

1
ssps•

You don’t need fuse if you don’t mount the remote. Copy, sync, ls, don’t require fuse.

1
binaryvisionsOP•

Right, okay fair point. The specific steps outlined here work without fuse, but this is only one component of what I am using rclone for, so fuse is necessary for me.

1