Git Backup Mod

Quick rating

Git Backup Mod

No reviews yet

Execute git commit && push on each auto save

No Theme
No Genre
Storage & Organization
Server Utility
Mod Loaders
Fabric
Minecraft
1.21

Community voices

Reviews

Versions
Loading versions…
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

Compatibility

Supported Environments

Dev Environment
Client Unsupported
Server Required

About

Project Details

Type
Mod
License
Creative Commons Attribution 4.0 International
Latest Version
Git Backup Mod 1.3.0 for Minecraft 1.21
Authors
CurseForge
Modrinth

For authors

Embed Badge

If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

CurseForge ID
Modrinth ID

Resources

External Links

Source Issues Wiki Discord

About

Description

What is this?

This mod hooks itself to built in save system and executes following commands:

  • git add <world name> for each loaded world
  • git commit -m "<current datetime>"
  • git pushall - it is custom command, yo need to define it

Generally minecraft runs auto save every 5 minutes (save-on to enable), you may force save by executing save-all or simply stop server.

Setup

  • Create repository next to world folder git init
  • Setup custom git pushall, see this on how to set up it
  • Done (this mod has no configuration)

What is this?

This mod hooks itself to built in save system and executes scripts:

Each script is executed in server root directory (next to .jar file) with the following arguments:

  • 1 - player count
  • 2 - average tick time (float)
  • 3 - server running ("true" or "false")
  • 4 - total level names
  • 5+ - level name #n (server may run multiple levels at once, level name is equal to directory name)

Each script is by default executed in /bin/bash, but you may provide your shell by editing mods/backup-scripts/shell file.

Init script:

This script is executed only if contains changes since last execution To manually force execution without changes delete .last-init-run file from mods/backup-scripts directory.

# Do not use Shebang here, change default shell by editing `shell` file
echo "Script PWD: $(pwd)"
echo "Arguments passed: $#"
echo "Player count: ${1}"
echo "AVG Tick time: ${2}"
echo "Server running: ${3}"
echo "Total levels: ${4}"
echo "Level names: '${*:5:$4}'"

echo "Creating git repository"
git init

levelNames=${*:5:$4}
for levelName in "${levelNames[@]}" # Preventing word splitting, because minecraft level names may contain spaces
do
    echo "Adding '$levelName' to repository"
    git add "$levelName"
done

echo "Creating initial commit"

git commit -m "Automatic backup - $(date)"
echo "Initialization done!"

Example output:

[15:52:21] [Server thread/INFO] (Minecraft) Done (15.286s)! For help, type "help"
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): Script PWD: /Users/mateusz.budzisz/git/fabric/git-backup-fabric-mod/run
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): Arguments passed: 4
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): Player count: 0
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): TPS: 0.0
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): Total levels: 1
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): Level names: 'world'
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): Creating git repository
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): Initialized empty Git repository in /Users/mateusz.budzisz/git/fabric/git-backup-fabric-mod/run/.git/
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): Adding 'world' to repository
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): Creating initial commit
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): [main (root-commit) a142833] Automatic backup - Sun Aug 13 15:52:21 CEST 2023
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  11 files changed, 1 insertion(+)
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  create mode 100644 world/entities/r.-1.-1.mca
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  create mode 100644 world/entities/r.-1.0.mca
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  create mode 100644 world/entities/r.0.-1.mca
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  create mode 100644 world/entities/r.0.0.mca
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  create mode 100644 world/level.dat
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  create mode 100644 world/poi/r.0.0.mca
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  create mode 100644 world/region/r.-1.-1.mca
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  create mode 100644 world/region/r.-1.0.mca
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  create mode 100644 world/region/r.0.-1.mca
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  create mode 100644 world/region/r.0.0.mca
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  create mode 100644 world/session.lock
[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): Initialization done!

OnSave script

This script is executed at every auto save (Minecraft performs auto save every 5 minutes, use save-on to enable), you may use save-all to force save. Default script contents:

# Do not use Shebang here, change default shell by editing `shell` file
echo "Script PWD: $(pwd)"
echo "Arguments passed: $#"
echo "Player count: ${1}"
echo "AVG Tick time: ${2}"
echo "Server running: ${3}"
echo "Total levels: ${4}"
echo "Level names: '${*:5:$4}'"

if [ "$1" -le 0 ] && [ "$3" = "true" ] ; then
  echo "Skipping backup as no one is online"
  exit 1
fi

# AVG tick time is float, hence this wierd comparison
if (( $(echo "$2 > 50" |bc -l) )) && [ "$3" = "true" ] ; then
  echo "Skipping backup as avg tick time is too high ($2)"
  exit 2
fi

levelNames=${*:5:$4}
for levelName in "${levelNames[@]}" # Preventing word splitting, because minecraft level names may contain spaces
do
    echo "Adding '$levelName' to commit"
    git add "$levelName"
done

echo "Creating commit"
git commit -m "Automatic backup - $(date)"
git push
echo "Backup done!"

Example output:

[15:43:50] [Server thread/INFO] (BackupScripts) Running scripts off main thread
[15:43:50] [Thread-13/INFO] (BackupScripts) (on-save.sh): Script PWD: /Users/mateusz.budzisz/git/fabric/git-backup-fabric-mod/run
[15:43:50] [Thread-13/INFO] (BackupScripts) (on-save.sh): Arguments passed: 4
[15:43:50] [Thread-13/INFO] (BackupScripts) (on-save.sh): Player count: 1
[15:43:50] [Thread-13/INFO] (BackupScripts) (on-save.sh): AVG tick time: 0.1340647
[15:43:50] [Thread-13/INFO] (BackupScripts) (on-save.sh): Total levels: 1
[15:43:50] [Thread-13/INFO] (BackupScripts) (on-save.sh): Level names: 'world with space in name'
[15:43:50] [Thread-13/INFO] (BackupScripts) (on-save.sh): Adding 'world with space in name' to commit
[15:43:50] [Thread-13/INFO] (BackupScripts) (on-save.sh): Creating commit
[15:43:50] [Thread-13/INFO] (BackupScripts) (on-save.sh): [main 7cd92d5] Automatic backup - Sun Aug 13 15:43:50 CEST 2023
[15:43:50] [Thread-13/INFO] (BackupScripts) (on-save.sh):  9 files changed, 0 insertions(+), 0 deletions(-)
[15:43:50] [Thread-13/INFO] (BackupScripts) (on-save.sh): Backup done!
[15:43:50] [Server thread/INFO] (BackupScripts) Shutdown of off main thread

Default scripts use GIT

Which is fine for small worlds (e.g.: up to few gigabytes), but it is recommended to setup more reliable solution as https://github.com/bup/bup or https://github.com/WayneD/rsync

Screenshots

Gallery

This project has no gallery images yet.

Versions

Files

Relations

Project Relations

More like this

Similar Mods

Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.

On ModDex

Community snapshot

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

~1,000
Total Downloads
CurseForge
<1,000
Modrinth
<1,000
Last Updated
CurseForge
Created
CurseForge
Modrinth
Last synced
When ModDex last fetched this project from CurseForge or Modrinth. Every project is re-checked on a schedule, and any project that ships a new file is synced automatically within hours of the release.
New file updates sync automatically
How syncing works