[Tutorial] How to sync saves/roms to the cloud

  • 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

    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

    case "$1" in
    # check that is online to run the first sync command
    while :
            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 $!
    # This is the main loop
    while :
            # 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 $!
    rclone copy /recalbox/share/saves/ gdmedia:rpi
    rclone copy /recalbox/share/saves/ gdmedia:rpi
    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


    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

  • @minze hey nice tutorial !

    A few things though :

    • you forgot a mount -o remount, rw /
    • i'd make it easier to edit the .sh files by either a sed command or wget the already ready files
    • starting it at S99 could be risky

  • Thank you ! 😀

  • Staff
    Global moderator

    @substring said in [Tutorial] How to sync saves/roms to the cloud:

    @minze hey nice tutorial !

    • starting it at S99 could be risky

    Why ?

  • @acris if the "drive" hasn't responded before you launch a rom, it's embarassing

  • @substring It's true I forgot that, is there any way to edit the post? Can't find it though I can for answers.
    And yeah it can be risky, I haven't thought about that

  • @minze editing posts is forbidden after a moment to prevent ppl changing their mind. The best would be to write it in the wiki

  • Staff
    Global moderator

Want to support us ?