From c1704b3a0aa0041c94f8b3e481cf85833eb3e03b Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt <2270806+jammsen@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:18:53 +0200 Subject: [PATCH] added backup-announce feature-toggle from #272 --- CHANGELOG.md | 3 +++ Dockerfile | 1 + default.env | 1 + docs/ENV_VARS.md | 1 + scripts/backupmanager.sh | 24 ++++++++++++++++-------- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fc272f..566bab4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog [Back to main](README.md#changelog) +## 2024-08-12 + +- added support to turn off backup-announcements, to have less spammy chat ingame, but errors will always be announced @Jadiction @jammsen (#272) ## 2024-06-24 diff --git a/Dockerfile b/Dockerfile index 5659687..363aff0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,6 +64,7 @@ ENV DEBIAN_FRONTEND=noninteractive \ STEAMCMD_VALIDATE_FILES=true \ # Backup-settings BACKUP_ENABLED=true \ + BACKUP_ANNOUNCE_MESSAGES_ENABLED=true \ BACKUP_CRON_EXPRESSION="0 * * * *" \ BACKUP_RETENTION_POLICY=true \ BACKUP_RETENTION_AMOUNT_TO_KEEP=72 \ diff --git a/default.env b/default.env index f365fdd..80f010f 100644 --- a/default.env +++ b/default.env @@ -7,6 +7,7 @@ ALWAYS_UPDATE_ON_START=true STEAMCMD_VALIDATE_FILES=true # Backup-settings BACKUP_ENABLED=true +BACKUP_ANNOUNCE_MESSAGES_ENABLED=true BACKUP_CRON_EXPRESSION=0 * * * * BACKUP_RETENTION_POLICY=true BACKUP_RETENTION_AMOUNT_TO_KEEP=72 diff --git a/docs/ENV_VARS.md b/docs/ENV_VARS.md index e6446d7..8be91f1 100644 --- a/docs/ENV_VARS.md +++ b/docs/ENV_VARS.md @@ -18,6 +18,7 @@ These settings control the behavior of the Docker container: | ALWAYS_UPDATE_ON_START | Updates the server on startup | true | Boolean | | STEAMCMD_VALIDATE_FILES | Set to enabled SteamCMD will also validate the gameserver files, making sure nothing is corrupted and also overwrite any file changes of the source | true | Boolean | | BACKUP_ENABLED | Backup function, creates backups in your `game` directory | true | Boolean | +| BACKUP_ANNOUNCE_MESSAGES_ENABLED | While creating backups, this controls if announces are posted to the gameserver; Important: Errors will always be announced! | true | Boolean | | BACKUP_CRON_EXPRESSION | Needs a Cron-Expression - See [Cron expression](#cron-expression) | 0 * * * * (meaning every hour) | Cron-Expression | | BACKUP_RETENTION_POLICY | Set to enabled, will cleanup old backups | true | Boolean | | BACKUP_RETENTION_AMOUNT_TO_KEEP | Defines how many backups in numbers to keep | 72 | Integer | diff --git a/scripts/backupmanager.sh b/scripts/backupmanager.sh index 5b21b21..d14118a 100644 --- a/scripts/backupmanager.sh +++ b/scripts/backupmanager.sh @@ -5,6 +5,7 @@ source /includes/colors.sh source /includes/rcon.sh # Default values if the environment variables exist +LOCAL_BACKUP_ANNOUNCE_MESSAGES_ENABLED=${BACKUP_ANNOUNCE_MESSAGES_ENABLED} # Defines if messages should be announced via rcon LOCAL_BACKUP_PATH=${BACKUP_PATH} # Directory where the backup files are stored LOCAL_GAME_PATH=${GAME_PATH} # Directory where the game save files are stored LOCAL_GAME_SAVE_PATH=${GAME_SAVE_PATH} # Directory where the game save files are stored @@ -136,19 +137,26 @@ function create_backup() { mkdir -p "${LOCAL_BACKUP_PATH}" - rconcli broadcast "$(get_time) Saving in 5 seconds..." - sleep 5 - rconcli broadcast "$(get_time) Saving world..." - rconcli save - rconcli broadcast "$(get_time) Saving done" - sleep 15 - rconcli broadcast "$(get_time) Creating backup..." + if [[ -n $LOCAL_BACKUP_ANNOUNCE_MESSAGES_ENABLED ]] && [[ $LOCAL_BACKUP_ANNOUNCE_MESSAGES_ENABLED == "true" ]]; then + rconcli broadcast "$(get_time) Saving in 5 seconds..." + sleep 5 + rconcli broadcast "$(get_time) Saving world..." + rconcli save + rconcli broadcast "$(get_time) Saving done" + sleep 15 + rconcli broadcast "$(get_time) Creating backup..." + else + rconcli save + fi + if ! tar cfz "${LOCAL_BACKUP_PATH}/${backup_file_name}" -C "${LOCAL_GAME_PATH}/" --exclude "backup" "Saved" ; then broadcast_backup_failed ee ">>> Backup failed" else - broadcast_backup_success + if [[ -n $LOCAL_BACKUP_ANNOUNCE_MESSAGES_ENABLED ]] && [[ $LOCAL_BACKUP_ANNOUNCE_MESSAGES_ENABLED == "true" ]]; then + broadcast_backup_success + fi es ">>> Backup '${backup_file_name}' created successfully" fi