Skip to content

Instantly share code, notes, and snippets.

@pilover100
Last active May 20, 2022 16:50
Show Gist options
  • Save pilover100/669a5e7f0da92c0a598c5ce2c9ebf0c4 to your computer and use it in GitHub Desktop.
Save pilover100/669a5e7f0da92c0a598c5ce2c9ebf0c4 to your computer and use it in GitHub Desktop.
Create Endless-Sky savegame snapshots automatically using git!

Git savegame repos

Ever wanted to be able to keep track of all your savegames without a faff? Well git can be used to easily keep track of all your saves automatically so you never need to worry again!

Setup

To start, you need to initilise a git repo in your savegame folder location

you can find your savegames in these locations

Linux: ~/.local/share/endless-sky/saves
Windows: %AppData%\endless-sky\saves

using either your favorite terminal emulator, or the console (linux) or cmd or powershell (windows) run these commands to initilise git:

git init
git add -A
git commit -m Initial

This will initilise the repo used to store your savegames.

Linux

To allow automatic saving of you save games, you will need to make a shell script and a crontab in linux, here I will provide a sh script but feel free to make your own.

the script:

cd ~/.local/share/endless-sky/saves
git add -A
git commit -m snapshot

My advice is to save it on your desktop for easy modification and to facilitate running whenever you need it (i.e. before testing a plugin).

Then run crontab -e to create a recuring job, you can replace the 5 with the number of minutes between each snapshot you want:

*/5 * * * * sh path_to_script.sh

Windows

Windows is very similar to linux except you will need a batch script instead, save it to your desktop.

The script:

ECHO off
cd %AppData%/endless-sky/saves
git add -A
git commit -q --message="savegame update"

Then run Task Scheduler to create a recurring task. The points below should walk you through it, pictures are attached.

  • On the right hand pane, select Create Task...
  • Give it a name such as ES auto snapshot
  • at the bottom, "Configure" it for your machine (default is Vista)

image

  • Goto the triggers tab and select New
  • Select Daily and adjuct the time to something reasonable like 10:00:00
  • Under Advanced, check the box Repeat task every: and adjust the time between repetitions to your liking and set the duration to 12 hours

image

  • Select Ok
  • Goto the actions tab and select New
  • Select browse and select your batch script, press ok

image

  • Your task is now done, press ok to save it.

General notes

If you ever need to run the scripts "on demand" because of save editing or new plugins, either commit manually or just run your script off the desktop.

This method will work for any savegames for most games out there, so feel free to use it for games other than Endless-Sky!

On Windows, you may occasionally see a cmd window appear, this is normal and is just down to how windows runs batch scripts.

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