|
|
备份脚本 (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
回复(0)
收起回复
|