21 Apr 2018, 14:44

Hello, I've managed to run rclone to have synced any folder on almost any cloud.
The clouds available are all those listed here: https://rclone.org/

Step 1: Download the necessary files.

open ssh and run those commands:

cd ~
mkdir -p rpi-sync    
wget -O rclone-install.sh https://raw.github.com/pageauc/rclone4pi/master/rclone-install.sh   
wget -O rclone-sync.sh https://raw.github.com/pageauc/rclone4pi/master/rclone-sync.sh   
wget -O rpi-sync/Readme.md https://raw.github.com/pageauc/rclone4pi/master/Readme.md

now we have all the necessary files, but we have to modify rclone-install.sh
run: nano ./rclone-install.sh
Delete all the sudo on the file, at the end you should have something like that:
0_1524321467750_Screenshot from 2018-04-21 16-33-36.png
now let's finish with the commands

chmod +x rclone-install.sh
chmod +x rclone-sync.sh
./rclone-install.sh 

Step 2: Add an account

Go to https://rclone.org/docs/ and pick any cloud service.
The steps don't change for Recalbox (at least for Google Drive, which is what I used).

Step 3: Execute it on start

Now that we can sync saves, it's time to automate it.
We have to create a startup script; run:

cd /etc/init.d/
nano ./S99Sync

Now we will create the startup script

#!/bin/bash
case "$1" in
        start)
# check that is online to run the first sync command
while :
do
        wget -q --spider http://google.com
        if [ $? -eq 0 ]; then
                # Run the command that will execute only once at the start
                # this is for GDive, it will copy every folder and file
                # and it'll delete those that have been deleted
                /usr/bin/rclone sync gdmedia:rpi /recalbox/share/saves/ &
                wait $!
                break
        else
        fi
done
# This is the main loop
while :
do
        # I prefer to have an external script to run my rclone commands
        /etc/init.d/Copy.sh &
        # the wait will make this script wait until the Copy.sh has finished
        # it's important not to run twice any rclone script at the same time
        wait $!
done
;;
stop)
rclone copy /recalbox/share/saves/ gdmedia:rpi
;;
restart|reload)
rclone copy /recalbox/share/saves/ gdmedia:rpi

;;
*)
esac

exit $?

Exit and save that file.
Now we will create the Copy.sh file that will have our scripts

nano ./Copy.sh

This is what I have:

/usr/bin/rclone copy /recalbox/share/saves/ gdmedia:rpi

This copies the new/modified folders/files from /recalbox/share/saves/ to my google drive folder called rpi
You can do whatever you want to be executed all the time there.
Now let's make them executable

chmod +x Sync
chmod +x Copy.sh

Perfect! now if you restart your recalbox.... it won't work.
Even though you can run it from any ssh and it'll work, it won't work itself we have to fix something more

Step 4: Make it work

make sure to do this step everytime that you change your rclone configuration.
You have to copy the rclone.conf from /recalbox/share/system/.config/rclone to /.config/rclone
I did it manually, but you should be able to do it with this command
cp -i /recalbox/share/system/.config/rclone/rclone.conf /.config/rclone

Problems

  1. The startup of any game will be from 1 to 15 seconds slower.

Special Thanks

Special thanks to @substring and @voljega for all the help provided to me with this.
And of course rclone for making this possible, and pageauc for making the rclone4pi

Sync more things than saves

I made that to only sync saves, but you are able to sync everything that you want, just change the folder where you want to sync and that you want to sync