Semi-automated backup and save transfer system using GIT

kohlrak

Farmhand
This is for those of you who keep loosing your tools or are wanting to keep backups and/or want to automate cross-save transfers. The setup is a little clinky, but after a while you are set.

For this, i'm using windows 7 and android, but the setup works with many other systems. GIT is a free and open source program that was intended for tracking small changes in source code for making games. However, it can be used for a multitude of file types. First, you'll need a copy of git. On android, i grabbed it using the Termux app and "apt install git" which is really easy. For other OSes (including windows), you need to find it here, unless on linux then you just use your package manager. Sorry for your loss if you're on iOS, but the solution costs 20 dollars, and i'm not even sure it would actually even work.

Next, you need to find your saves. Now, you have an option. Once you actually get started, your "repository" is based on it's location. You can either take the option of storing your entire save directory (all your saves) or saves themselves. Now, for me, the Bash interface is easier, but for some it's not. I'm starting this on windows, since that's what most people will have, but this also applies to Android and others as well. I typed "git init[enter]" and "git add *" and "git commit -a[enter]" and Click here to see how this turned out. Since i used "vim" as my editor, i had to hit "i" to start editing, then i hit escape then ":wq[enter]" to save and quit, which then allowed me to create a log.

Bash:
$ git log
commit de74dd59e131fc3f2137f3e5050b7afc5246a041 (HEAD -> master)
Author: Kohlrak (Laptop) <[email protected]>
Date:   Mon Apr 13 22:41:05 2020 -0400

    Starting.
The hex-decimal hash string after "commit" is necessary for backing up. Any time i want to make a new backup, all i have to do is type "git commit -a" and repeat that step. The hidden folder called ".git" will maintain the changelog and stuff for me. If you delete this folder, your backups are gone. If i want to go back to this starting save, i can just "git reset --hard de74dd59e131fc3f2137f3e5050b7afc5246a041" and it goes back to that save. Beware, this can delete all newer backups. To avoid this, you might want to consider a separate location and either using the "clone" option or by pushing to another location. Any time you wnat to add a new save, you'll also need to use "git add *" if you're using your whole save directory, rather than 1 repository per folder. For most people, this is really all the more you'll need, if you don't want to do save transfering.

Now, for this example of save transfers, since most people arne't likely to have an SSH server, i've made a new repository on github! I recommend you do this, but if you already have an SSH server, it's probably better to use that. Github conveniently wrote some code for me to copy and paste!

Bash:
git remote add origin https://github.com/kohlrak/stardewvalleysaves.git
git push -u origin master
Login, everything goes fine. Now, to move these saves to android, I used Termux and typed "cd /sdcard/StardewValley[enter]". Now, for the first time, this are a little messy. First, i need to type "git clone https://github.com/kohlrak/stardewvalleysaves.git" then I need to type "mv stardewvalleysaves/.git/ ./" and then "mv stardewvalleysaves/* ." to move .git and the other files over. "*" won't automatically include files and folders whose name begins with a period, since they're "hidden files" so i have to do them explicitly. From here, i typed "rm -R stardewvalleysaves/" to delete that folder, then i have the power to add my android saves to the repot by typing "git add *" and then "git commit -a". Just like on windows. Now, "git commit -a" does not automatically upload the saves. To upload, you must type "git push." To download, changes, you type "git pull." No need to type more than that (aside from "git commit -a" for creating "restore points").

If you forget to "git push" before you "git pull" you can easily create a conflict that is not easily resolved. As a general rule, you want to type "git commit -a" after every time you see that the game is saved. When you quit playing, type "git push." Before you start playing again, type "git pull." If you keep to these rules, you should have no problems, except when the game version mismatches. Be careful with updating your game. However, i just verfied that my save from the GOG edition of Stardew Valley works with my Android edition of the game. For those of you whom only play stardew valley, you can add the "cd /sdcard/StardewValley" to the end of "~/.bashrc" using vim (the thing that requires i to type and esc and :wq to exit) via "vim ~/.bashrc" and using the arrow keys to get all the way to the bottom of the file, hitting i, typing that line without quotes, and then hitting escape, then :wq. This way, every time you open to termux, you would be right in that folder. However, this is not recommend long term, because if you want to use this method with other games (I started doing this with The Quest by Redshift), you'll find it difficult. You can also create "bash scripts" using vim, then use "./nameofscripthere.sh" to auto execute commands, which is useful for those games that like to hide in places like "/sdcard/Android/data/app_name_here/files/saves" which can be an annoyance getting to. Don't froget you can "autocomplete" with "tab," which is to the right of "esc".
 

kohlrak

Farmhand
Thanks for sharing!
np. I doubt this was clear enoguh, so i'm sure someone looking at this didn't do it right, but no feedback, yet, so i don't know how to improve. Oh well. Worst case scenariro, someone better at writing tutorials will eventually figure it out.

EDIT: Somehow did not catch that this board existed. I was trying to figure out if i should post in general or mods, but then somehow totally missed this one.
 
Last edited:
Top