itzg / itzg/docker-mc-backup

Add a PRE_SAVE_SCRIPT environment variable

Open
#127 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
538
Forks
69
Avg merge
3h 28m
Merged PRs (30d)
2

Description

It would be nice to have a PRE_SAVE_SCRIPT / PRE_SAVE_SCRIPT_FILE environment variable where the script is executed before "[/save-off](https://github.com/itzg/docker-mc-backup/blob/fed5a0adce71e15380cf9fdb847728da7f983bec/backup-loop.sh#L441)". Most of the time when the server executes a "[/save-all](https://github.com/itzg/docker-mc-backup/blob/fed5a0adce71e15380cf9fdb847728da7f983bec/backup-loop.sh#L446)" 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](https://github.com/itzg/docker-mc-backup/blob/fed5a0adce71e15380cf9fdb847728da7f983bec/backup-loop.sh#L458) and "[/save-on](https://github.com/itzg/docker-mc-backup/blob/fed5a0adce71e15380cf9fdb847728da7f983bec/backup-loop.sh#L455)".

If this gets added the [lines](https://github.com/itzg/docker-mc-backup/blob/master/backup-loop.sh#L435)
```
log INFO "waiting for rcon readiness..."
retry ${RCON_RETRIES} ${RCON_RETRY_INTERVAL} rcon-cli save-on
```
should probably be moved inside the [while loop](https://github.com/itzg/docker-mc-backup/blob/fed5a0adce71e15380cf9fdb847728da7f983bec/backup-loop.sh#L439) to make sure that PRE_SAVE_SCRIPT doesn't get called if the server is offline

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in backup-loop.sh around the save-off and save-on commands referenced in the issue, then trace the surrounding while loop and existing POST_BACKUP_SCRIPT handling. Define the environment-variable behavior and ordering for PRE_SAVE_SCRIPT and PRE_SAVE_SCRIPT_FILE, including the offline-server case. Done means the pre-save hook runs at the requested point without running when the server is offline.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
devops
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.