mojira.dev
MC-122295

Backups folder is created outside of the server directory when using a dedicated server

On startup, the server attempts to create a backups folder as ../backups (i.e. a folder one folder up from its work location/"universe"), apparently for use when converting non-anvil worlds. This is problematic, because e.g. on shared hosts this location may not have write access, so the server will fail to start (but even ignoring that issue, it is confusing to put the backups folder outside of the server itself ("why is there suddenly an empty backups folder here?")).

The failed startup can be reproduced when launching a server on windows within your user directory (C:\Users\<USERNAME>) from an account that doesn't have permission to write to C:\Users. Doing so causes the server to fail to start, with this error message (quoting @unknown from MC-122621):

[17:28:32] [main/FATAL]: Failed to start the minecraft server
java.lang.RuntimeException: java.nio.file.AccessDeniedException: C:\Users\Dusty\.\..\backups
        at bix.<init>(SourceFile:36) ~[minecraft_server.17w48a.jar:?]
        at biu.<init>(SourceFile:38) ~[minecraft_server.17w48a.jar:?]
        at net.minecraft.server.MinecraftServer.<init>(SourceFile:197) ~[minecraft_server.17w48a.jar:?]
        at px.<init>(SourceFile:71) ~[minecraft_server.17w48a.jar:?]
        at net.minecraft.server.MinecraftServer.main(SourceFile:748) [minecraft_server.17w48a.jar:?]
Caused by: java.nio.file.AccessDeniedException: C:\Users\Dusty\.\..\backups
        at sun.nio.fs.WindowsException.translateToIOException(Unknown Source) ~[?:1.8.0_151]
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source) ~[?:1.8.0_151]
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source) ~[?:1.8.0_151]
        at sun.nio.fs.WindowsFileSystemProvider.createDirectory(Unknown Source) ~[?:1.8.0_151]
        at java.nio.file.Files.createDirectory(Unknown Source) ~[?:1.8.0_151]
        at java.nio.file.Files.createAndCheckIsDirectory(Unknown Source) ~[?:1.8.0_151]
        at java.nio.file.Files.createDirectories(Unknown Source) ~[?:1.8.0_151]
        at bix.<init>(SourceFile:34) ~[minecraft_server.17w48a.jar:?]
        ... 4 more

Original description:

Tried with both the above versions of Java, cant start a fresh world or a world created with last weeks snap.

With Java 8 fails with this output:

[10:23:22] ain/FATAL]: Failed to start the minecraft server
java.lang.RuntimeException: java.nio.file.AccessDeniedException: /var/games/minecraft/servers/Flat_1_13_Dev/./../backups
at bis.<init>(SourceFile:36) ~inecraft_server.17w47a.jar:?]
at bip.<init>(SourceFile:38) ~inecraft_server.17w47a.jar:?]
at net.minecraft.server.MinecraftServer.<init>(SourceFile:194) ~inecraft_server.17w47a.jar:?]
at pw.<init>(SourceFile:71) ~inecraft_server.17w47a.jar:?]
at net.minecraft.server.MinecraftServer.main(SourceFile:744) inecraft_server.17w47a.jar:?]
Caused by: java.nio.file.AccessDeniedException: /var/games/minecraft/servers/Flat_1_13_Dev/./../backups
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) ~[?:1.8.0_131]
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:1.8.0_131]
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:1.8.0_131]
at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384) ~[?:1.8.0_131]
at java.nio.file.Files.createDirectory(Files.java:674) ~[?:1.8.0_131]
at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781) ~[?:1.8.0_131]
at java.nio.file.Files.createDirectories(Files.java:767) ~[?:1.8.0_131]
at bis.<init>(SourceFile:34) ~inecraft_server.17w47a.jar:?]
... 4 more

Java 9 this output:

[10:22:34] ain/FATAL]: Failed to start the minecraft server
java.lang.RuntimeException: java.nio.file.AccessDeniedException: /var/games/minecraft/servers/Flat_1_13_Dev/./../backups
at bis.<init>(SourceFile:36) ~inecraft_server.17w47a.jar:?]
at bip.<init>(SourceFile:38) ~inecraft_server.17w47a.jar:?]
at net.minecraft.server.MinecraftServer.<init>(SourceFile:194) ~inecraft_server.17w47a.jar:?]
at pw.<init>(SourceFile:71) ~inecraft_server.17w47a.jar:?]
at net.minecraft.server.MinecraftServer.main(SourceFile:744) inecraft_server.17w47a.jar:?]
Caused by: java.nio.file.AccessDeniedException: /var/games/minecraft/servers/Flat_1_13_Dev/./../backups
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?]
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) ~[?:?]
at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:385) ~[?:?]
at java.nio.file.Files.createDirectory(Files.java:682) ~[?:?]
at java.nio.file.Files.createAndCheckIsDirectory(Files.java:789) ~[?:?]
at java.nio.file.Files.createDirectories(Files.java:775) ~[?:?]
at bis.<init>(SourceFile:34) ~inecraft_server.17w47a.jar:?]
... 4 more

Box itself is only a couple of months old. Have done all the obvious, updates & patches all to latest. Deleted and re-downloaded jar file etc.

Working fine with last weeks snaps by no joy with this one.

Edit: Same behavior is 17w47b

Linked issues

Comments 6

Weird that the server is accessing directories outside the current dir.

Can you try chown-ing /var/games/minecraft/servers/backups to your user?

(Edit) It does seem to create a backup dir in the parent dir for me. You should create it (may require sudo, which is why the server can't create it) then chown it to your user.

Its an odd one isn't it. Manually creating the directory does allow the server to start so that's great, many thanks 😃.
But is the backup file really supposed to be outside the server instance directory?

I've got a random cron.config xml file in that backup directory, is that the same behavior you observed?

I didn't find such a file in that directory---it was empty for me.

This bug persists in 17w48a. Directly referencing the parent directory when creating a new directory is poor design because it makes assumptions about what insight the running application has into permissions and directory structure outside of its own working directory. For example, this choice prevents servers from starting if the system user has no permission to write to the parent directory. The server should not try to modify data outside of its folder. Client behavior could be different understandably, but the server should respect these expectations.

Had the same issue. Creating a "backup" directory one level higher and setting permissions for the server instance would allow the server to start.

Please don't let server instances do anything outside of their own working directories. This will mess things up for a lot of people.

Also please disable backups by default. Almost everybody already has backup solutions for Minecraft server instances. We don't need a copy outside the working directory when we're already backing up off-site.

Take lessons from what Forge did. Every time a mod would change on your instance, it would back up your entire world. This was a huge problem for servers that had really big worlds and the server would compress 100GB+ into a .zip archive. Please don't backup every time the server starts or something like that. And if you do make backups, at least do incrementals so unchanged data isn't copied needlessly.

Also please disable backups by default. Almost everybody already has backup solutions for Minecraft server instances. We don't need a copy outside the working directory when we're already backing up off-site.

I believe the only automatic backup is the one when converting non-anvil worlds (~1.1?) to anvil worlds (which generated what effectively was a backup before due to the way the converter works). It just creates the backup folder even if it doesn't need to...

Ian Collett

Nathan Adams

Confirmed

Minecraft 17w47a, Minecraft 17w47b, Minecraft 17w48a

Minecraft 17w49a

Retrieved