Skip to content

Instantly share code, notes, and snippets.

@partlyhuman
Last active April 10, 2022 20:57
Show Gist options
  • Save partlyhuman/83168bcac27cc74254509f3edcaa115a to your computer and use it in GitHub Desktop.
Save partlyhuman/83168bcac27cc74254509f3edcaa115a to your computer and use it in GitHub Desktop.
Retropie cloud saves

First, set up a samba server on a machine on your network that's always on. I have a Pi Zero acting as a pi-hole on 10.0.0.2 (see www.pi-hole.net), piggybacking on this. I only mention because the pi-hole project slaps. Your machine can be anything, Windows is great too since it has built in Samba, DLNA all sorts of fun sharing protocols.

To set that up on pi you can follow a guide like https://magpi.raspberrypi.org/articles/samba-file-server. Windows is much easier, just share a folder under Properties, Sharing.

So now I have a server share //10.0.0.2/share with a saves/ subfolder

On every RetroPie device, I now want to do two things:

  1. Mount the share on boot up

    1. Ensure the samba client is installed with sudo apt update && sudo apt install samba samba-common-bin smbclient cifs-utils
    2. Edit the file /opt/retropie/configs/all/autostart.sh below
  2. Set up the emulators to use that share for save files and save states

    1. Edit the file /opt/retropie/configs/all/retroarch.cfg below
    2. Sometimes individual emulators override this, so if it's not working comment out the savestate_directory and savefile_directory lines in any other /opt/retropie/configs/*/retroarch.cfg
    3. To do this in one fell swoop: sed -i 's/^savefile_directory/#savefile_directory/g' /opt/retropie/configs/*/retroarch.cfg and sed -i 's/^savestate_directory/#savestate_directory/g' /opt/retropie/configs/*/retroarch.cfg
    4. Oops, if you did above, you also modified your /all/ config, so reapply that change. I would have told you to do that last but it's the most important change. Heh.
# in file /opt/retropie/configs/all/autostart.sh
emulationstation & #auto
# As long as pinging the samba server fails (returns nonzero), keep trying
while ! ping -c 1 -W 1 10.0.0.2; do
sleep 1
done
# Now network should be reachable
# IMPORTANT: forceuid and uid=pi make the folder read/writable as pi user instead of root
# The username/password options are for the samba share user. Could also be guest if you set it up that way.
sudo mount.cifs //10.0.0.2/share /media/share -o rw,username=pi,password=xxx,forceuid,uid=pi
# in file /opt/retropie/configs/all/retroarch.cfg
#Save all save files (*.srm) to this directory. This includes related files like .bsv, .rtc, .psrm, etc ...
#This will be overridden by explicit command line options.
savefile_directory = "/media/share/saves"
#Save all save states (*.state) to this directory.
#This will be overridden by explicit command line options.
savestate_directory = "/media/share/saves"
@partlyhuman
Copy link
Author

Be careful when using newer builds with very old builds — I've noticed SNES savestates that the older build fails to read. Nothing worse than losing progress. You may want to run a cron script to back up your saves! Use rsync and crontab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment