In this tutorial i will show you how to synchronise any files with your Raspberry PI using OneDrive as the example. For this project i am just going to synchronise my Documents folder from OneDrive. You can also use this for many other types of drives eg. Google Drive or Dropbox and the process is very similar. Just choose a different number in step 6.

  1. First open a Terminal window sand enter curl -L https://raw.github.com/pageauc/rclone4pi/master/rclone-install.sh | bash
  2. Once this has finished you are ready to configure Rclone
  3. Enter the command rclone config
  4. Enter n (for a new connection) and then press enter
  5. Enter a name for the connection (i’ll enter onedrive) and press enter
  6. Enter 18 for Google Drive and press enter
  7. Press Enter for client ID
  8. Press Enter for Client Secret
  9. Press n and enter for edit advanced config
  10. Enter y for auto config and then press enter
  11. A browser window will now open, log in with your Microsoft Account and select yes to allow OneDrive access.
  12. You will then see “success”
  13. Now choose 1 for OneDrive Personal or Business
  14. Now select the OneDrive you would like to use, you will probably only have one OneDrive linked to your account. This will be 0
  15. Now select y for yes
  16. Now select y for yes again
  17. Close the terminal window
  18. Using a web browser or phone app, In your Google drive create a folder to syncs; i’ll call mine Documents
  19. Now we have set up the connection however we still have to synchronise the folder with the raspberry PI. To do this we will write a simple .sh script and set it to run at a set time.
  20. First open a terminal and test your sync command. rclone sync -v onedrive:Documents /home/pi/Documents This command will sync the “onedrive” connection “Documents” folder to your raspberry pi. The contents will be downloaded to you documents folder on the pi. If successful you will see the terminal start downloading each file to the folder.
  21. Now to make it automatic. If your comfortable with a text editor you can enter this string into leafpad on the raspberry pi and save it as sync.sh rclone sync -v onedrive:Documents /home/pi/Documents
  22. If you have used different names to me, replace drive with your connection name and replace Documents with your folder name. You can also change the path, this is where the folder is synced to.
  23. Put the file in the /home/pi/Documents on your Raspberry Pi
  24. This file will call the connection and download any new files from OneDrive.
  25. Next we will install a tool to set the script to run automatically. Open a terminal and enter sudo apt-get install gnome-schedule
  26. Enter your password and once the installation is completed close the terminal
  27. Open the Raspberry Pi menu and under System Tools open Scheduled Tasks
  28. Select New and then A Task that launches recurrently
  29. Enter a Description if you like. In the command box enter /home/pi/Documents/sync.sh
  30. Next you can enter the times for synchronisation, i’m going to leave it as default; which syncs every hour. Feel free to change this to your liking
  31. Then Click add
  32. Thats it! Restart your Raspberry Pi and add files to your OneDrive

I use this to synchronise photos to my raspberry pi Photo frame project.