Skip to content

Commit e6fb4c1

Browse files
authored
Add BACKUP_ON_STARTUP option (#198)
1 parent 12d78eb commit e6fb4c1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Provides a side-car container to back up [itzg/minecraft-server](https://github.
1515
- `BACKUP_METHOD`=tar : [see below](#backup-methods)
1616
- `INITIAL_DELAY`=2m
1717
- `BACKUP_INTERVAL`=24h
18+
- `BACKUP_ON_STARTUP`=true : Set to false to skip first backup on startup.
1819
- `PAUSE_IF_NO_PLAYERS`=false
1920
- `PLAYERS_ONLINE_CHECK_INTERVAL`=5m
2021
- `PRUNE_BACKUPS_DAYS`=7

scripts/opt/backup-loop.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fi
1919
: "${BACKUP_NAME:=world}"
2020
: "${INITIAL_DELAY:=2m}"
2121
: "${BACKUP_INTERVAL:=${INTERVAL_SEC:-24h}}"
22+
: "${BACKUP_ON_STARTUP:=true}"
2223
: "${PAUSE_IF_NO_PLAYERS:=false}"
2324
: "${PLAYERS_ONLINE_CHECK_INTERVAL:=5m}"
2425
: "${BACKUP_METHOD:=tar}" # currently one of tar, restic, rsync
@@ -575,9 +576,13 @@ if ! is_one_shot; then
575576
sleep ${INITIAL_DELAY}
576577
fi
577578

579+
first_run=TRUE
578580

579581
while true; do
580-
if ! is_paused; then
582+
if [[ $first_run == TRUE && ${BACKUP_ON_STARTUP^^} = FALSE ]]; then
583+
log INFO "Skipping backup on startup"
584+
first_run=false
585+
elif ! is_paused; then
581586

582587
load_rcon_password
583588

0 commit comments

Comments
 (0)