Bedrockifier icon indicating copy to clipboard operation
Bedrockifier copied to clipboard

Add features to run backup on container startup

Open aanglere opened this issue 1 year ago • 6 comments

I looked through the wiki and noticed that there was no initial backup created when the container starts or an method to run the backup on-demand.

I worked around it by creating another container with interval set to 5 minutes that I manually stop/start on-demand. However, I think we would all benefit if these features were included and we can fallback on automation once more.

Thanks for developing Bedrockifier. It was just what I needed to manage backups for both Bedrock and Java servers.

aanglere avatar Oct 23 '24 21:10 aanglere

Sorry for the delay here. I'm going to split this into two issues, as there's really two requests as I read it:

  • Need a way to ask for initial backups.
  • Need a way to ask for a backup outside the usual schedule.

As the second piece is a bit more complicated (and relies on other work I haven't done yet), I've split that to #98.

I'm working on a quick flag to do a backup after the startupDelay has occurred.

Kaiede avatar Dec 06 '24 17:12 Kaiede

This feature is now available on the test tag if you want to take a look. It will be available in latest with the next release (1.4 or 1.3.2, not sure which at this point).

Kaiede avatar Dec 06 '24 20:12 Kaiede

This feature is now available on the test tag if you want to take a look. It will be available in latest with the next release (1.4 or 1.3.2, not sure which at this point).

Where can I find this test tag? I'd also like 3 things to be improved on this awesome backup thingy you've made (Bedrockifier and docker-minecraft-bedrock-backup):

  • On-demand backups, so that I can manually backup when ever I want
  • Force creating a backup on server startup (ignore any schedules/trims/events/anything)
  • Scheduled backups only when there are players online

I haven't had any issues, so I don't have any specific use case to back these up, but for the sake "makes more sense" adding all the three features would eventually make backups more flexible, customisable and save disk space.

My conf is like this at the moment:

containers:
  bedrock:
    - name: minecraft_urpotrio
      ssh: minecraft_urpotrio:2222
      passwordFile: /server/.remote-console.yaml
      worlds:
        - /server/worlds/UrpoTrio

trim:
  # Keep all backups for the last two days (today and yesterday)
  trimDays: 2
  # Keep at least one backup for the last 7 days
  keepDays: 7
  # Keep at least two backups per world
  minKeep: 2

schedule:
  # Trigger backup every two hours.
  interval: 2h

  # Whenever a player logs in.
  onPlayerLogin: true
  # Whenever a player logs out.
  onPlayerLogout: true
  # Whenever the last player logs out
  onLastLogout: true
  # Limit backups to maximum once per 5 minutes
  minInterval: 5min

loggingLevel: debug

The config above will contain backups for:

  • at least once per two hours, for the past 2 days
  • at least one backup per day for 7 days
  • at least 2 backups per world (forever?)
  • at most it will contain 600 backups for the past 2 days (minInterval 5min, if I keep restarting or a player keeps re-joining the server once every 5 minutes) + one for the past 5 days

For example:

  1. If I started the stack now and no one joined the server for 10 days, I would have dozens (29) of "identical" copies of backups, with the only difference being the "Days played", as no one would've been on the server doing nothing. At the moment my backups are ~450Mb each, so this would mean 29 * 450MB = ~13GB of backups, while I could manage with having only the one backup from the timestamp when I started the stack (total size of the backups would be 450MB) and once the first player joins after the 10 days, it would create a separate backup (total size of 900MB) and the only difference between these two backups would be that the first one is e.g. "Days played 2000" and the latter when the player joined would be "Days played 2720". There's no workaround for this, other than me creating another script that would store history of when there are players and if any new backups are being created during the 0 player time, my script would need to delete any newly created backups.
  2. If I knew that we're going to make a risky move, like going with all the best gear – we've had to grind dozens of hours for – with us for example for the Nether, I'd like to trigger a backup before we go, just for the sake of being able to restore it, if things go south. Currently my workaround is to trigger the backup by having the minInterval set to e.g. 5min, at least one player having to leave and re-join the server, to trigger a new backup.
  3. Automatic backups on server launch would make sense. Workaround for this as well is to have the minInterval set to e.g. 1min and onPlayerLogin: true, so when I launch the stack, I need to wait e.g. 1minute before joining the server and then I'd basically have the backup for when the server was started.

But as I said, I can workaround with all the above, by just adjusting the current configs, especially playing around with the interval and minInterval.

My current situation looks like this (screenshots from my Home Assistant (yes, I've created some custom integrations between Home Assistant (smarthome) and my Minecraft server): Image On the left side you can see when there were players on the server and on the right side you can see the list of backups I have with the setup above.

Image

Image

So these 3 backups I currently have, have been taken when there was 0 players online and nothing changing apart for the Days played on the server, so basically I have 1.3GB of completely "waste of space" backups from last night.

Image

Kirbo avatar Jan 28 '25 14:01 Kirbo

Sorry for the lag getting to this:

Where can I find this test tag?

It's a docker container tag like latest (the default if you don't specify one). So you'd specify it when configuring your container in compose/etc: kaiede/minecraft-bedrock-backup:test. Same as using a specific version of a container.

As for the list of asks, these are all being tracked already as enhancements.

  • On-demand backups, so that I can manually backup when ever I want - #98
  • Force creating a backup on server startup (ignore any schedules/trims/events/anything) - This Issue
  • Scheduled backups only when there are players online - #103

Both this, and #98 are in progress. Most of the work behind #98 is done, but there's some issues that need to be resolved before it is ready to deploy.

Kaiede avatar Mar 04 '25 19:03 Kaiede

It's a docker container tag like latest (the default if you don't specify one). So you'd specify it when configuring your container in compose/etc: kaiede/minecraft-bedrock-backup:test. Same as using a specific version of a container.

For some reason I was trying to find a git tag instead of docker tag 🤦 😅

So it's this? https://hub.docker.com/layers/kaiede/minecraft-bedrock-backup/test/images/sha256-f9de49039d6e3fee1ec91fe1952725ddd6722d9d41375e48dbd5f0233c7e7862?context=explore

Kirbo avatar Mar 05 '25 06:03 Kirbo

Yes.

Automated workflows update that docker tag whenever work is merged into main, so it’s the bleeding edge, and what I use in my personal setup to try to root out issues in changes when possible.

The behavior was added in #99, and describes the new flag in the config to enable it. Wiki will be updated when I finish the HTTP REST API work which brings the on-demand backup behavior and release 1.4. It’s just been a very weird winter so I haven’t had the energy to follow up on the changes, but I do want to get them pushed out soon-ish.

Kaiede avatar Mar 05 '25 15:03 Kaiede