safeguard (by sorcerykid)
Filesystem Safeguard Mod performs a routine check of the mounted filesystems containing the Minetest debug log and world directory, and performs an immediate shutdown of the Minetest server if the available space is below a predefined threshold. This helps to protect against catastrophic data loss on production servers, including corruption of the map database.
Note: This mod will only work under Linux, since it performs a "df" shell command. It is also necessary to patch the Minetest engine with the minetest.get_system_path() API function in script/lua_api/l_util.cpp as shown below:
Code: Select all
// get_system_path( filespec )
int ModApiUtil::l_get_system_path( lua_State *L )
{
NO_MAP_LOCK_REQUIRED;
std::string filespec = luaL_checkstring( L, 1 );
if( filespec == "debug.txt" ) {
lua_pushstring( L, g_log_filename.c_str( ) );
}
else if( filespec == "minetest.conf" ) {
lua_pushstring( L, g_settings_path.c_str( ) );
}
else if( filespec == "minetestserver" ) {
char buf[ BUFSIZ ];
bool success =
porting::getCurrentExecPath( buf, sizeof( buf ) ) ||
porting::getExecPathFromProcfs( buf, sizeof( buf ) );
lua_pushstring( L, buf );
}
else {
lua_pushnil( L );
}
return 1;
}
Code: Select all
min_world_free_space = 500 -- in megabytes
min_debug_free_space = 10 -- in megabytes
check_period = 30 -- in minutes
Code: Select all
2022-09-12 21:50:18: ACTION[Main]: [safeguard] Performing initial filesystem analysis...
868580 MB used 727 MB free 100% usage /home/minetest/.minetest/test.log
868580 MB used 727 MB free 100% usage /home/minetest/.minetest/worlds/test
2022-09-12 21:50:18: WARNING[Main]: [safeguard] Shutting down server to avoid potential data loss...
https://bitbucket.org/sorcerykid/safeguard
Download Archive (.zip)
Download Archive (.tar.gz)
Dependencies:
Configuration Panel Mod (config)
Timekeeper Mod (timekeeper)
Source Code License:
The MIT License (MIT)
Installation:
- Unzip the archive into the mods directory of your game
- Rename the safeguard-master directory to "safeguard"