Rclone is an open source command line program to sync files and directories to and from local storage to cloud based storage, such as OneDrive for Business.
Setting up an rclone Environment
From a terminal on NX run the following command to setup your environment. This is a one time operation as the configuration is held in your home directory.
No remotes found - make a new one n) New remote s) Set configuration password q) Quit config n/s/q>
No remote environments exist yet, so we will select ‘n’
You will then be asked to choose a name for the connection. We recommend using ‘remote’ as this is the same as our examples below.
n/s/q> n name> remote
From the list of options select the one for Microsoft One Drive. In our example below it’s 21, please check the list on your screen as option numbers can change in future versions.
21 / Microsoft OneDrive \ "onedrive" Storage> 21 Microsoft App Client Id - leave blank normally. client_id> Microsoft App Client Secret - leave blank normally. client_secret> Edit advanced config? (y/n) y) Yes n) No y/n> n Remote config Use auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine y) Yes n) No y/n> y If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth Log in and authorize rclone for access Waiting for code... Got code
Firefox will then be launched requesting a login to OneDrive for Business. This is your UoR UPN (e.g. XY123456@reading.ac.uk) and password.
Once you have logged you will be asked for the type OneDrive i.e personal/business and select the drive you want to use from those found.
Choose a number from below, or type in an existing value 1 / OneDrive Personal or Business \ "onedrive" 2 / Root Sharepoint site \ "sharepoint" 3 / Type in driveID \ "driveid" 4 / Type in SiteID \ "siteid" 5 / Search a Sharepoint site \ "search" Your choice> 1 Found 1 drives, please select the one you want to use: 0: OneDrive (business) id=b!CuZrqPHEFU636x6rqYAhRKnMdCmvgrLQQDmo-AoHYueOlvEmgiQHbbL Chose drive to use:> 0 Found drive 'root' of type 'business', URL: https://livereadingac-my.sharepoint.com/personal/a_n_other_reading_ac_uk/Documents Is that okay? y) Yes n) No y/n> y
You then need to confirm your environment Select ‘y‘ to save and then ‘q‘ to quit the setup.
Initiating a Backup to OneDrive
List directories in top level of your OneDrive
rclone lsd remote:
List all the files in your OneDrive
rclone ls remote:
To copy a local directory to an OneDrive directory called backup
rclone copy ~/source remote:backup
To copy a network directory to an OneDrive directory called network
rclone copy /storage/silver/example remote:net/example
To mount your OneDrive directory using fusemount into your home directory
rclone --vfs-cache-mode writes mount remote: ~/OneDrive &
Note that OneDrive is case insensitive so you can’t have a file called “Hello.doc” and one called “hello.doc”.
There are quite a few characters that can’t be in OneDrive file names. These can’t occur on Windows platforms, but on non-Windows platforms they are common. Rclone will map these names to and from an identical looking unicode equivalent. For example if a file has a ? in it will be mapped to ？instead.
The largest allowed file size is 100GiB as of 17th June 2020
If you don’t use rclone for 90 days the refresh token will expire. This will result in authorization problems. This is easy to fix by running the following command to get a new token and refresh token.
rclone config reconnect remote
For older versions of rclone you have to use the edit command to refresh the token
rclone config edit
See using rclone with onedrive for more information