Source-checkedTechnology & automation

Backup Scripts

by electroluxv2 · for Minecraft

Execute your scripts at builtin save system events.

919Downloads
2 yr agoLast updated
CC-BY-4.0License
FabricLoaders

About Backup Scripts

From Modrinth

Execute your scripts at builtin save system events.

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

Read the full description on Modrinth →

Highlights

From source data

Game versions

Supports 3 Minecraft versions, the newest being 1.21.

Loaders

Runs on Fabric.

Footprint

Rated a light load on a server.

Backup Scripts on Nxeon

From our catalogue
One-click install
Supported on Nxeon Minecraft servers. We download it from Modrinth, place it, and restart the server.
Server side
Required on the server
Server type needed
Fabric
Server load
light
Smallest plan we suggest
Minecraft — 2 GB (2 GB RAM). This follows our own load rating above, not a benchmark.
Latest build
1.3.0, released 2024-07-22

Game versions by loader

LoaderGame versionsNewest
Fabric1.20.1 to 1.21 (3 versions)1.21

From 5 recorded builds of Backup Scripts.

Recent builds

BuildReleasedGame versionsLoaders
1.3.02024-07-221.21Fabric
1.2.12023-12-271.20.4Fabric
1.2.02023-09-061.20.1Fabric
1.1.02023-08-131.20.1Fabric
1.0.02023-08-101.20.1Fabric

Dependencies

  • Required: modrinth project P7dR8mSH (modrinth, not in our catalogue)

Declared by the newest build that lists any. Required ones are installed with it on one-click installs.

Run Backup Scripts on a Minecraft server

Pick a server or deploy a new one above; it is installed in one click.

What kind of mod it is

From the catalog
Listed on Modrinth as “Mods”

Technology & automation

Machines, power, logistics and automation.

Runs on your server

From source side support

Modrinth lists Backup Scripts as required on the server. Check its Modrinth page to see whether players need it too.

Compatibility

Game
Minecraft
Loaders
Fabric
Runs on
Serverrequired on the server
Game versions
1.21 and 2 earlier

Verified at the source

  • ✓ModrinthOfficial listing, checked 2026-10-03Open ↗
  • ✓Authorelectroluxv2, as published on Modrinth
  • ✓LicenseCC-BY-4.0Free

Backup Scripts, answered

Generated from the mod’s own source data.

Do my players need to install Backup Scripts?

Modrinth lists Backup Scripts as required on the server. Check its Modrinth page to see whether players need it too.

Which loaders does it support?

Fabric.

Is it free?

Yes. Backup Scripts is free to download from Modrinth. Its license is CC-BY-4.0.

How do I add it to my Nxeon server?

Use “Add to a server” on this page, or open NxLabs from your dashboard. We install it, restart your server and switch it on.

NxLabs

Run Backup Scripts on a Minecraft server.

Deploy in about a minute from $4.99 a month, then add Backup Scripts in one click.