itzg / docker-mc-backup

Provides a side-car container to backup itzg/minecraft-server world data
https://hub.docker.com/r/itzg/mc-backup
MIT License
334 stars 52 forks source link

Add a PRE_SAVE_SCRIPT environment variable #127

Open Alb11747 opened 1 year ago

Alb11747 commented 1 year ago

It would be nice to have a PRE_SAVE_SCRIPT / PRE_SAVE_SCRIPT_FILE environment variable where the script is executed before "/save-off". Most of the time when the server executes a "/save-all" it freezes the server for a few seconds. I would be nice to be able to announce to the players, "Server Backup starting in x seconds". Another use cases might be to perform cleanup task like removing drop entities with "/lagg clear", etc... It would be nice to also add a POST_SAVE_SCRIPT but spot is already taken by POST_BACKUP_SCRIPT. I don't know if it would be a breaking change to swap the order of POST_BACKUP_SCRIPT and "/save-on".

If this gets added the lines

log INFO "waiting for rcon readiness..."
retry ${RCON_RETRIES} ${RCON_RETRY_INTERVAL} rcon-cli save-on

should probably be moved inside the while loop to make sure that PRE_SAVE_SCRIPT doesn't get called if the server is offline

itzg commented 1 year ago

That seems like reasonable additions. Like you said, just need to confirm the sequence of those with other operations. That would be great if you could PR this.