auth_rx_wiki/Advanced-Database-Import.md

3.1 KiB

While the convert.awk script populates most fields with nil values, the extract.awk script will analyze your debug.txt file and generate a transaction log that can be applied to the authentication database, giving you an accurate historic record of player login activity (dating as far back as your debug logs go, at least) -- including values for OldLogin, Lifetime, TotalSessions, and TotalFailures. This step, of course, is entirely optional and can be skipped.

I stress tested the script on the debug log from JT2 dating back to December 2016. The input file size was 11.0 GB, and it only took about 9 minutes and 30 seconds to complete the operation. Despite the myriad of server crashes and missing accounts that accumulated in my debug log before I developed this mod, it still churned out some impressive results!

The parser is sophisticated enough to compensate for inconsistencies between the authentication database and the debug log. It will also detect server startup, shutdown, and abnormal termination events which are necessary for calculating session lengths. Unfortunately, client connections are not logged (in the vanilla Minetest config), so TotalAttempts is the only statistic that is unavailable using this method.

For more detailed output from the script, you can change the debug level to 'verbose'. This will display both errors and warnings. It might be helpful to redirect output to a temporary file for this purpose. To see only errors, the default debug level of 'terse' should be sufficient.

> awk -f extract.awk -v debug=verbose /tmp/auth.txt /home/minetest/.minetest/debug.txt

Warnings occur if there are orphaned accounts in the auth.txt file that do not appear in the corresponding debug log. This happens when the debug log is incomplete. Orphaned accounts will have no player login activity applied. Errors occur if the auth.txt file is inconsistent with the debug log. This could be the result of a server crash or intentional deletion of accounts. Such accounts are deemed invalid and player login activity will be ignored. However, you should verify that you are using the correct auth.txt file.

Afterward, it is simply a matter of replaying the import journal against the newly converted database using the provided rollback.lua script. The import journal must reside in the same directory as the database to be updated.

The rollback.lua script will automatically backup the import journal by renaming it "~auth.dbx". It will also prepare an empty journal within the same directory.

Here is the required sequence of commands to perform a conversion and extraction:

> cd auth_rx/tools
> awk -f convert.awk -v mode=convert ~/.minetest/worlds/world/auth.txt
> awk -f extract.awk -v debug=terse ~/.minetest/worlds/world/auth.txt ~/.minetest/debug.txt
> lua rollback.lua ~/.minetest/worlds/world/auth.db

You are now ready to start your Minetest server with a fully populated authentication database. Congratulations!