Advanced Backups

Advanced Backups

1M Downloads

Restore backup doesn't work if worlds are not in root folder

UnderscoreBay opened this issue · 2 comments

commented

Describe the bug
Backups are not listed when restoring if the server world data is not at the root of the minecraft folder as expected.

To Reproduce
Steps to reproduce the behavior:

  1. Have minecraft world data in another folder.
  2. Try to restore a backup from the backups folder.
  3. World is not listed.

Expected behavior
The tool should also pull configuration from server.properties to find the location of the world on the disk.

Versioning (please complete the following information):

  • OS: Oracle Linux 9
  • Minecraft Version(s): 1.21.4
  • Modloader(s): Fabric
  • Mod Version: 1.21

Additional context
Having a folder path instead of a single name is a supported feature of the server.properties file, so the tool should work with this.

commented

Having a folder path instead of a single name is a supported feature of the server.properties file, so the tool should work with this.

I'll admit that I was completely unaware of this.

With that said - currently, the cli checks for a presence of a level.dat within a directory to know whether it's a world or not. This is mainly done because world can be named anything, and non-world dirs can be present within both the server root and a client's saves directory.

This will be reworked, likely in 4.0 when the SPI system gets implemented. The full CLI needs a rewrite anyway, as it's become too burdened by tech debt and trying to improve my multi-year old code is painfully slow.

commented

I am afraid that I have to raise one more issue with the CLI. When backup folder is set to relative path begin with (or including, I don't know) folder .., although the mod runs backups just fine, the restore process redirects the backup folder starting with .. For example, say I set backup folder to be ../Backups, the restore script resolves the path to minecraft/mods/.Backups. I seems like it has something to do with this:

//What's a good way to check between absolute and relative? Not all absolute paths will start with /..
File backupDir = new File(serverDir, backupLocation.replaceAll(Pattern.quote("." + File.separator), ""));
if (!backupDir.exists()) {
//Is it absolute?
backupDir = new File(backupLocation.replaceAll(Pattern.quote("." + File.separator), ""));
if (!backupDir.exists()) {
CLIIOHelpers.error("Could not find backup directory!");
CLIIOHelpers.error(backupDir.getAbsolutePath());
CLIIOHelpers.error("Have you made any backups before?");
//Fatal, cannot continue
return;
}
}

But since you're planning a full rewrite, I'll currently using symlink to address this. It works well. I still want you to be aware of this to avoid potential issues in the future. 😉