docker-mc-backup icon indicating copy to clipboard operation
docker-mc-backup copied to clipboard

Add a PRE_SAVE_SCRIPT environment variable

Open Alb11747 opened this issue 2 years ago • 1 comments

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

Alb11747 avatar Feb 21 '23 10:02 Alb11747

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.

itzg avatar Feb 23 '23 20:02 itzg