Skip to content

Commit

Permalink
added backup-announce feature-toggle from #272
Browse files Browse the repository at this point in the history
  • Loading branch information
jammsen committed Aug 12, 2024
1 parent cd54514 commit c1704b3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions default.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/ENV_VARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
24 changes: 16 additions & 8 deletions scripts/backupmanager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c1704b3

Please sign in to comment.