搜索历史
清空
暂无搜索历史
论坛热搜
1
Jenny — 有趣的模拟女友模组|珍妮模组
热
3
上古老物 冒险者传说 by WhiteSword
新
5
洛心斗罗-福利|公会据点战|武魂||抽奖|最终版
2
乌托邦探险之旅3.2
热
4
幻虚斗罗V1.5
6
水星迫降——在未知的世界中挣扎
登陆 注册 QQ登陆
快捷导航
查看: 107|回复: 0

[模组分享] 备份脚本 (Backup Scripts)-MOD模组

[复制链接]

5159

主题

5

回帖

6143

积分

龙❁妻

Rank: 8Rank: 8

经验
6143 EP
金粒
929 粒
绿宝石
20 块
爱心
0 点
发表于 2025-8-10 16:48:19 | 显示全部楼层 |阅读模式
备份脚本 (Backup Scripts)Github |相关wiki |源站链接支持: fabric在内置保存系统事件中执行您的脚本。

---

备份脚本(Backup Scripts)模组会连接到内置保存系统并执行脚本:

*每个脚本都在服务器根目录(与 .jar 文件相邻)中执行,具有以下参数:*

- `1` - 玩家数量

- `2` - TPS(每秒钟的游戏刻)

- `3` - 总的世界名数量

- `4+` - 世界名 #n(服务器可能同时运行多个世界,世界名等同于目录名)

每个脚本默认以 `/bin/bash` 执行,但您可以通过编辑 `mods/backup-scripts/shell` 文件来提供自己的 shell。

初始化脚本:

*此脚本仅在自上次执行以来包含更改时执行*

要在没有更改的情况下强制执行,请从 `mods/backup-scripts` 目录中删除 `.last-init-run` 文件。

bash

请勿在此处使用注释,通过编辑 `shell` 文件更改默认 shell

echo \"脚本目录: $(pwd)\"

echo \"传递的参数数量: $#\"

echo \"玩家数量: ${1}\"

echo \"TPS: ${2}\"

echo \"总的世界数量: ${3}\"

echo \"世界名: \'${*:4:$3}\'\"

echo \"创建 Git 仓库\"

git init

worldNames=${*:4:$3}

for worldName in \"${worldNames[@]}\" # 避免单词拆分,因为 Minecraft 世界名可能包含空格

do

    echo \"将 \'$worldName\' 添加到仓库\"

    git add \"$worldName\"

done

echo \"创建初始提交\"

git commit -m \"自动备份 - $(date)\"

echo \"初始化完成!\"

示例输出:

[15:52:21] [Server thread/INFO] (Minecraft) 完成 (15.286s)! 如需帮助,请输入“help”

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): 脚本目录: /Users/mateusz.budzisz/git/fabric/git-backup-fabric-mod/run

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): 传递的参数数量: 4

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): 玩家数量: 0

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): TPS: 0.0

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): 总的世界数量: 1

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): 世界名: \'world\'

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): 创建 Git 仓库

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): 在 /Users/mateusz.budzisz/git/fabric/git-backup-fabric-mod/run/.git/ 中初始化空的 Git 仓库

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): 将 \'world\' 添加到仓库

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): 创建初始提交

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): [main (root-commit) a142833] 自动备份 - Sun Aug 13 15:52:21 CEST 2023

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  11 个文件已更改,1 处插入(+)

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  新建模式 100644 world/entities/r.-1.-1.mca

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  新建模式 100644 world/entities/r.-1.0.mca

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  新建模式 100644 world/entities/r.0.-1.mca

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  新建模式 100644 world/entities/r.0.0.mca

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  新建模式 100644 world/level.dat

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  新建模式 100644 world/poi/r.0.0.mca

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  新建模式 100644 world/region/r.-1.-1.mca

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  新建模式 100644 world/region/r.-1.0.mca

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  新建模式 100644 world/region/r.0.-1.mca

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  新建模式 100644 world/region/r.0.0.mca

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh):  新建模式 100644 world/session.lock

[15:52:21] [Server thread/INFO] (BackupScripts) (init.sh): 初始化完成!

在保存时脚本

*此脚本在每次自动保存时执行(Minecraft 每 5 分钟执行一次自动保存,使用 `save-on` 可启用),您可以使用 `save-all` 强制保存。*

默认脚本内容:

bash

请勿在此处使用注释,通过编辑 `shell` 文件更改默认 shell

echo \"脚本目录: $(pwd)\"

echo \"传递的参数数量: $#\"

echo \"玩家数量: ${1}\"

echo \"TPS: ${2}\"

echo \"总的世界数量: ${3}\"

echo \"世界名: \'${*:

来自Modrinth所有游戏版本1.211.20.41.20.1所有类型fabricGit Backup Mod 1.3.0 for Minecraft 1.21backup-scripts-1.3.0.jar下载1.3.0#Releasebackup-scripts-1.3.0-sources.jar下载1.3.0#Release## 1.3.0- Updated to minecraft 1.21.0- Added server running argument- Improved shutdown behaviour to wait for file handlers to close- Changed default scripts to always perform backup on server shutdown## 1.2.1- Updated to minecraft 1.20.4- Changed script argument tick time to AVG tick time## 1.2.0- Removed waiting for `on-save.sh` at server tick, now script may run as long as server is still running- Moved scripts directory to `config` directory- Changed script parameter from TPS to tick time- Adjusted script output logging, now standard output and standart error are read at the same time, so potential warnings are in correct order of occurrence among normal messagesThanks @wereii and @NekoNoor for reporting issues.## 1.1.0- Extracted logic to user defined scripts## 1.0.0- Initial release展开版本: 1.3.0支持游戏: 1.21类型:FabricRelease下载次数: 97Git Backup Mod 1.2.1 for Minecraft 1.20.4backup-scripts-1.2.1.jar下载1.2.1#Releasebackup-scripts-1.2.1-sources.jar下载1.2.1#Release## 1.2.1- Updated to minecraft 1.20.4- Changed script argument tick time to AVG tick time## 1.2.0- Removed waiting for `on-save.sh` at server tick, now script may run as long as server is still running- Moved scripts directory to `config` directory- Changed script parameter from TPS to tick time- Adjusted script output logging, now standard output and standart error are read at the same time, so potential warnings are in correct order of occurrence among normal messagesThanks @wereii and @NekoNoor for reporting issues.## 1.1.0- Extracted logic to user defined scripts## 1.0.0- Initial release展开版本: 1.2.1支持游戏: 1.20.4类型:FabricRelease下载次数: 126Git Backup Mod 1.2.0 for Minecraft 1.20.1backup-scripts-1.2.0.jar下载1.2.0#Releasebackup-scripts-1.2.0-sources.jar下载1.2.0#Release## 1.2.0- Removed waiting for `on-save.sh` at server tick, now script may run as long as server is still running- Moved scripts directory to `config` directory- Changed script parameter from TPS to tick time- Adjusted script output logging, now standard output and standart error are read at the same time, so potential warnings are in correct order of occurrence among normal messagesThanks @wereii and @NekoNoor for reporting issues.## 1.1.0- Extracted logic to user defined scripts## 1.0.0- Initial release展开版本: 1.2.0支持游戏: 1.20.1类型:FabricRelease下载次数: 149Git Backup Mod 1.1.0 for Minecraft 1.20.1backup-scripts-1.1.0.jar下载1.1.0#Releasebackup-scripts-1.1.0-sources.jar下载1.1.0#Release## 1.1.0- Extracted logic to user defined scripts## 1.0.0- Initial release展开版本: 1.1.0支持游戏: 1.20.1类型:FabricRelease下载次数: 127Git Backup Mod 1.0.0 for Minecraft 1.20.1git-backup-1.0.0.jar下载1.0.0#Releasegit-backup-1.0.0-sources.jar下载1.0.0#Release## 1.0.0- Initial releas展开版本: 1.0.0支持游戏: 1.20.1类型:FabricRelease下载次数: 149全部版本

markdown_parsed

文章类型:收录

layui.use([\'form\'], function(){
var form = layui.form;
});

游客,如果您要查看本帖隐藏内容请回复
备份脚本
楼主 2025-8-10 16:48:19 回复 收起回复
小僵尸论坛感谢有你~
回复 论坛版权

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 手机动态码快速登录

本版积分规则



介绍

我的世界(Minecraft)小僵尸论坛
收录了来自各地的我的世界(MC)爱好者们的各种资源

须知: 切勿滥用举报,任何与举报相关的信息必须属实!

"Minecraft"以及"我的世界"为Mojang Synergies AB的商标 本站与Mojang以及微软公司没有从属关系

官方

新浪微博 腾讯微博 微信公众号 投稿规则 版权声明 捐助我们

官方QQ①群: 291907844 (点击加群)
官方QQ②群: 421312192
官方QQ③群: 528726532

我的世界(Minecraft)小僵尸论坛

新会员

QQ|Archiver|手机版|小黑屋|Minecraft(我的世界)小僵尸论坛 |网站地图

GMT+8, 2026-4-18 20:06 , Processed in 0.783611 second(s), 152 queries .

快速回复 返回顶部 返回列表