If you have read my other project where i created a Raspberry Pi photo frame, then this is another extension of that. You could however use this to synchronize any files with your Raspberry PI. For this project i am just going to synchronize my sideshow photos from Google drive.

  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 drive) and press enter
  6. Enter 12 for Google Drive and press enter
  7. Press Enter for client ID
  8. Press Enter for client Secret
  9. Enter 1 and press enter
  10. Press Enter for ID of Root folder
  11. Press Enter for service account credentials
  12. Press n and enter for edit advanced config
  13. Enter y for auto config and then press enter
  14. A browser window will now open, log in with your Google account
  15. You will then see “success”
  16. Using a web browser or phone app, In your Google drive create a folder for the images; i’ll call mine images
  17. Enter n for configure as team drive and press enter
  18. Enter y and press enter to add the connection
  19. Close the terminal window
  20. Now we have set up the connection however we still have to synchronize 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.
  21. 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 drive:images /home/pi/Documents
  22. If you have used different names to me, replace drive with your connection name and replace images with your folder name. You can also change the path, this is where the folder is synced to.
  23. If you don’t want to make the file yourself you can download the version at the end of this project already completed, You will just need to unzip it
  24. Either way you do it put the file in the /home/pi/Documents on your Raspberry Pi
  25. Make it Executable, in the terminal chmod +x /home/pi/Documents/sync.sh
  26. This file will call the connection and download any new files from Google Drive. This is good however we need to set it to run automatically
    1. Only follow if your Pi doesn’t have a Desktop installed (Headless) or you have installed Raspian Buster– Run crontab -e  in the terminal
    2. Select 2 for nano
    3. Enter the following string – 0 * * * * /home/pi/Documents/sync.sh 
    4. Save the file ( usually Ctrl + O to save and Ctrl + X to exit) ,then skip to step 33
  27. (Depreciated, Gnome Schedule has been removed as of Raspian Buster. Only use if you have an older version. Use step 25.1 if you have Raspian Buster or newer) Next we will install a tool to set the script to run automatically. Open a terminal and enter sudo apt-get install gnome-schedule Enter your password and once the installation is completed close the terminal
  28. Open the Raspberry Pi menu and under System Tools open Scheduled Tasks
  29. Select New and then A Task that launches recurrently
  30. Enter a Description if you like. In the command box enter /home/pi/Documents/sync.sh
  31. Next you can enter the times for synchronization, i’m going to leave it as default; which syncs every hour. Feel free to change this to your liking
  32. Then Click add
  33. Thats it! Restart your Raspberry Pi and add some photos to your Google drive

PS. You can also use this for many other types of drives and the process is very similar. Just choose a different number in step 6.

sync.sh Zip File