Skip to content

Commit

Permalink
Allow disable compression by setting -a to "none"
Browse files Browse the repository at this point in the history
  • Loading branch information
draoncc committed Mar 10, 2024
1 parent 8a04318 commit f2f4138
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This will show chat messages (`-c`) and save a backup of `/home/user/server/worl

Command line options:
```text
-a Compression algorithm (default: gzip)
-a Compression algorithm (default: gzip). Set to "none" for no compression
-c Enable chat messages
-d Delete method: thin (default), sequential, none
-e Compression file extension, exclude leading "." (default: gz)
Expand Down
6 changes: 3 additions & 3 deletions backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SERVER_WORLDS=() # Server world directory
BACKUP_DIRECTORY="" # Directory to save backups in
MAX_BACKUPS=128 # -1 indicates unlimited
DELETE_METHOD="thin" # Choices: thin, sequential, none; sequential: delete oldest; thin: keep last 24 hourly, last 30 daily, and monthly (use with 1 hr cron interval)
COMPRESSION_ALGORITHM="gzip" # Leave empty for no compression
COMPRESSION_ALGORITHM="gzip" # Set to "none" for no compression
COMPRESSION_FILE_EXTENSION=".gz" # Leave empty for no compression; Precede with a . (for example: ".gz")
COMPRESSION_LEVEL=3 # Passed to the compression algorithm
ENABLE_CHAT_MESSAGES=false # Tell players in Minecraft chat about backup status
Expand Down Expand Up @@ -50,7 +50,7 @@ while getopts 'a:cd:e:f:hH:i:l:m:o:p:qr:s:t:u:vw:x' FLAG; do
f) TIMESTAMP=$OPTARG ;;
h) echo "Minecraft Backup"
echo "Repository: https://github.com/nicolaschan/minecraft-backup"
echo "-a Compression algorithm (default: gzip)"
echo "-a Compression algorithm (default: gzip). Set to \"none\" for no compression"
echo "-c Enable chat messages"
echo "-d Delete method: thin (default), sequential, none"
echo "-e Compression file extension, exclude leading \".\" (default: gz)"
Expand Down Expand Up @@ -499,7 +499,7 @@ do-backup () {

case $COMPRESSION_ALGORITHM in
# No compression
"") tar -cf "$ARCHIVE_PATH" "${SERVER_WORLDS[@]}"
"none") tar -cf "$ARCHIVE_PATH" "${SERVER_WORLDS[@]}"
;;
# With compression
*) tar -cf - "${SERVER_WORLDS[@]}" | $COMPRESSION_ALGORITHM -cv -"$COMPRESSION_LEVEL" - > "$ARCHIVE_PATH" 2>> /dev/null
Expand Down
4 changes: 2 additions & 2 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ assert-equals-directory () {
fi
if [ -d "$1" ]; then
for FILE in "$1"/*; do
assert-equals-directory "$FILE" "$2/${FILE##$1}"
assert-equals-directory "$FILE" "$2/${FILE##"$1"}"
done
else
assertEquals "$(cat "$1")" "$(cat "$2")"
Expand Down Expand Up @@ -255,7 +255,7 @@ test-backup-spaces-in-directory () {

test-backup-no-compression () {
TIMESTAMP="$(date +%F_%H-%M-%S --date="2021-01-01")"
./backup.sh -a "" -e "" -i "$TEST_TMP/server/world" -o "$TEST_TMP/backups" -s "$SCREEN_TMP" -f "$TIMESTAMP"
./backup.sh -a "none" -e "" -i "$TEST_TMP/server/world" -o "$TEST_TMP/backups" -s "$SCREEN_TMP" -f "$TIMESTAMP"
check-backup "$TIMESTAMP.tar"
}

Expand Down

0 comments on commit f2f4138

Please sign in to comment.