Skip to content

Commit 2f6ea32

Browse files
committed
Number of package backups can be configured with PACKAGE_BACKUP_KEEP
#150
1 parent f4081e0 commit 2f6ea32

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ For Minecraft Java Edition you'll need to use this image instead:
3838
bedrock server process
3939
- `GID` (default derived from `/data` owner) : can be set to a specific group ID to run the
4040
bedrock server process
41+
- `PACKAGE_BACKUP_KEEP` (`2`) : how many package backups to keep
4142

4243
### Server Properties
4344

bedrock-entry.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ if [ ! -f "bedrock_server-${VERSION}" ]; then
8383
fi
8484

8585
# remove only binaries and some docs, to allow for an upgrade of those
86-
rm -rf bedrock_server *.so release-notes.txt bedrock_server_how_to.html valid_known_packs.json premium_cache 2> /dev/null
86+
rm -rf bedrock_server bedrock_server-* *.so release-notes.txt bedrock_server_how_to.html valid_known_packs.json premium_cache 2> /dev/null
8787

8888
bkupDir=backup-pre-${VERSION}
8989
# fixup any previous interrupted upgrades
@@ -97,6 +97,15 @@ if [ ! -f "bedrock_server-${VERSION}" ]; then
9797
fi
9898
done
9999

100+
# remove old package backups, but keep PACKAGE_BACKUP_KEEP
101+
if (( ${PACKAGE_BACKUP_KEEP:=2} >= 0 )); then
102+
shopt -s nullglob
103+
for d in $( ls -td1 backup-pre-* | tail +$(( PACKAGE_BACKUP_KEEP + 1 )) ); do
104+
echo "Pruning $d"
105+
rm -rf $d
106+
done
107+
fi
108+
100109
# Do not overwrite existing files, which means the cleanup above needs to account for things
101110
# that MUST be replaced on upgrade
102111
unzip -q -n ${TMP_ZIP}

0 commit comments

Comments
 (0)