FreeNAS Sync to Onedrive with Cloud Sync on FreeNAS

Ryan_21

Cadet
Joined
Apr 13, 2016
Messages
6
I noticed in the freenas legacy on 11.2 beta 1 that Microsoft Onedrive has been added with the Freenas Cloud Sync Service but I don't know how to get an access code could somebody guide me how to do this in depth.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
you will need to run rclone config

As you run through the steps in a shell on FreeNAS, you find that you need to have rclone running on another machine that can open a browser to get you to the end.

When asked if you are on a remote or headless machine, this is the point where you select no (not auto) and are prompted to run a command on the machine with a browser and give the output to the process on FreeNAS to continue.

I didn't get there yet as I need to get to my own systems at home to go further, but you may be able to work it out by just following the steps.
 

Ryan_21

Cadet
Joined
Apr 13, 2016
Messages
6
you will need to run rclone config

As you run through the steps in a shell on FreeNAS, you find that you need to have rclone running on another machine that can open a browser to get you to the end.

When asked if you are on a remote or headless machine, this is the point where you select no (not auto) and are prompted to run a command on the machine with a browser and give the output to the process on FreeNAS to continue.

I didn't get there yet as I need to get to my own systems at home to go further, but you may be able to work it out by just following the steps.
Yes but I want to use the inbuilt with in the Gui.
 

Attachments

  • Screenshot_20180725-191418_Chrome.jpg
    Screenshot_20180725-191418_Chrome.jpg
    71.3 KB · Views: 4,558
  • Screenshot_20180725-191435_Chrome.jpg
    Screenshot_20180725-191435_Chrome.jpg
    112.8 KB · Views: 4,740

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Ryan_21 said:
Yes but I want to use the inbuilt with in the Gui.

Right. And to do that, you need the token that comes from doing what I mentioned.
 
Last edited:

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I can now confirm that I have used the method I mention above to produce the token and used it with success to create a sync (in the GUI) from FreeNAS 11.2 Beta1 to Onedrive personal.

All of the command line interactions with rclone are clear and relatively easy to read. the token is a big one, but it's clear where it starts and ends (the curly braces need to be included in what you paste back from your browser-enabled machine).

I personally used a Pine64 running debian (arm64) to have rclone on a box with a browser, so needed to download the .deb package from debian.org and install it with dpkg... I didn't do any searching on availability for MacOS or windows (nor any other linux variant), but I presume they exist and could be used in the same way. Also TrueOS could be an option if you really like FreeBSD.

I don't think Onedrive supports non-secure communication, so it's my assumption that data in transit is encrypted... someone to confirm if that's interesting to do.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
When asked if you are on a remote or headless machine, this is the point where you select no (not auto) and are prompted to run a command on the machine with a browser
Or, IIRC (from setting up Google Drive with rclone), you answer yes and it gives you a URL to visit on a machine with a browser, which doesn't need to run rclone. Although this may vary depending on the backend.

Really seems kind of an awkward way to do the setup, though.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
IIRC (from setting up Google Drive with rclone), you answer yes and it gives you a URL to visit on a machine with a browser, which doesn't need to run rclone. Although this may vary depending on the backend.

Based on what I saw, it seemed that rclone establishes a secure connection and then offers the url on a port (that I didn't note and may be random) on https://127.0.0.1:port/... to connect to. it mentions that url if the automatic launching of it doesn't work, but I don't see how this could work on a machine not running that process from rclone... so seems for that specific backend, it's not so clean (although not really that complicated since the token is then portable to as many FreeNAS or other boxes as you want as far as I can see and only really took me 10 minutes from start to finish to do).
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I wonder if the rclone integration (at least by 11.2 stable) will allow for encryption using existing keys. I have 20+ TB backed up to Google Drive and encrypted using rclone at the command line, but it'd be nice to have automated jobs handle ongoing synchronization without having to re-upload everything.
 

nathank1989

Contributor
Joined
Aug 29, 2016
Messages
103
Would anyone mind pointing to a guide for how to achieve this? I'm not quite sure what all the steps and commands are based off the information in this thread.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Would anyone mind pointing to a guide for how to achieve this? I'm not quite sure what all the steps and commands are based off the information in this thread.
Run recline configuration and answer the questions/follow the prompts on a machine that has a browser. You will then have the token needed to use the gui process to create a cloud credential. Then create a cloud sync using the credential.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Run recline configuration and answer the questions/follow the prompts on a machine that has a browser. You will then have the token needed to use the gui process to create a cloud credential. Then create a cloud sync using the credential.
Should be "rclone config". Autocorrect is not my friend.
 

nathank1989

Contributor
Joined
Aug 29, 2016
Messages
103
Am I right in understanding that I have to run that command on a whole separate machine with rclone and a GUI browser to then acquire and copy the key?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Am I right in understanding that I have to run that command on a whole separate machine with rclone and a GUI browser to then acquire and copy the key?
Yes, that is correct (for OneDrive). The login process uses a forms-based login, so can't be done at CLI.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Fortunately, rclone runs on just about every OS out there, including Windows.
Even if you want to keep your Windows box clean, a quickly installed linux build as a VM on FreeNAS would do it for the single use.

Plenty of options and easy to do.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Isn't rclone a static binary under Windows? It is under Linux, MacOS, and FreeBSD. If that's the case, just run it and delete it. Or a Linux VM on FreeNAS. Or under VirtualBox. Or... Lots of ways to skin this cat.
 

nathank1989

Contributor
Joined
Aug 29, 2016
Messages
103
Yes, that is correct (for OneDrive). The login process uses a forms-based login, so can't be done at CLI.

Ok so I ran it and got the
Code:
 token = {"access_token":"XXXXXXXXXXXXXXXXXXXXXXXXXX","expiry":"2018-08-22........."} 


Do I copy Everything inside the {}, just the Token? Do I include the expiry? Resource URL?

Right now I have copied everything inside the "" after access_token and before expiry and I run a sync task but nothing happens and I find no errors in /var/log/messages or middleward and nothing has synced to the onedrive


EDIT 1: Found a log and I get this error:

Code:
Failed to configure OneDrive: invalid character ',' after top-level value



EDIT 2:

Now I copied everything after "token = " and now I get this error:

Code:
 Failed to create file system for "remote:NAS_BACKUP": failed to get root: Get https://api.onedrive.com/v1.0/drive/root/: oauth2: cannot fetch token: 400 Bad Request Response {"error":"invalid_grant","error_description":"The provided value for the input parameter 'refresh_token' or 'assertion' is not valid."}
 
Last edited:

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I used the arrows to point me to the token which meant that the curly braces were part of it, but nothing before or after them.
 

nathank1989

Contributor
Joined
Aug 29, 2016
Messages
103
I used the arrows to point me to the token which meant that the curly braces were part of it, but nothing before or after them.
Yes, this got me to another error:

Code:
Failed to create file system for "remote:NAS_BACKUP": failed to get root: Get https://api.onedrive.com/v1.0/drive/root/: oauth2: cannot fetch token: 400 Bad Request Response {"error":"invalid_grant","error_description":"The provided value for the input parameter 'refresh_token' or 'assertion' is not valid."}
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
The token expires relatively quickly... you may need to generate another one.

Make sure you take everything including the curly braces (but stopping at that) from the result out of rclone config
 
Top