How to Schedule Upload to S3 AFTER the Game Server is Started Again?

I have a Minecraft instance running on a Linux machine with 30Mb/s upload speed. Every 24 hours a schedule rules to “Shut the server down, take a backup, and start it up again” with the option to upload S3 set to true. This all works great, except the Minecraft server is down for ~20 minutes while the S3 upload is conducted. However, the server only needs to be shut down during the backup, not the S3 upload. How can I schedule the backup to be uploaded to S3 after the server is started up again?

Thank you for your help,
Lloyd

The Shut the server down, take a backup, and start it up again task would be blocking in all three of it’s “stages”, so to get things working a bit quicker you’d have to split things up a bit.

Not 100% sure if this will work, but here’s an idea:

Trigger 1 (timed trigger):

  • Stop Server
  • Wait 60 (in case the server takes a bit)
  • Take a Backup (with S3 enabled)

Trigger 2 (When a scheduled backup finishes archiving):

  • Start server

I think it should fire that event once the backup zip is “done”, but before it starts uploading to S3, allowing the server to start while that’s going on.

That’s a great idea! I just gave it a try, and unfortunately it doesn’t appear to work. It runs the “A scheduled backup finishes archiving” trigger after the S3 backup is done. Here is a screenshot of the schedules I set it.

Do you know the command that AMP runs to trigger an S3 upload? If so, would it be possible for me to run a custom command after starting the server, running a shell file or so?

AMP doesn’t use a command to trigger S3, AMP uses the C# S3 SDK inside the panel’s backup plugin.
Depending on the mods you have running on the server, you might be able to back up while the server is running, since AMP runs the save-off command before doing so (so it’s safe as long as the mods are also abiding by that).

If it does seem to work fine while running, you could set up a timed trigger to run ~15-30min after the server restarts.

Thank you for the solution! This works great. We are only using a couple of Fabric quality of life mods like Lithium and BlueMap, so I hope it is safe.

The only noticeable downside of this solution is that automatic saving is off until the entire process has finished, which could take 30 minutes or more as the world size increases. Do you know of any negative consequences for auto-saving being off for an extended period of time?

Any particular reason why you recommended ~15-30 minutes after the restart? Just to give the restart ample time to finish?

Yeah, the tradeoff there is that the changes to the world won’t be solidified until autosaving resumes, which if the server crashes during that time you’d loose that progress. If the server you’re running doesn’t crash all that often it would probably be fine, just something to note for that larger backup.
Just came to mind though, you could exclude the BlueMap directory from the backups, since that’s all info that’s “technically” recoverable, you’d just have to regenerate it. That might help the size a tad.

And yeah the ~15-30min after the restart is just to make sure that the server has fully started and is ready to receive the save-all and save-off commands, as otherwise the backup would be taken while the server is starting up, and that may lead to a corrupted backup under the right conditions. (AMP should fail the backup in such cases though since the files would be in-use)