inital commit for adding spigot-paper worldnaming compatibility
This commit is contained in:
parent
34503cfbd8
commit
476ce5800f
1 changed files with 17 additions and 2 deletions
19
backup.sh
19
backup.sh
|
@ -23,6 +23,7 @@ SUPPRESS_WARNINGS=false # Suppress warnings
|
||||||
LOCK_FILE="" # Optional lock file to acquire to ensure two backups don't run at once
|
LOCK_FILE="" # Optional lock file to acquire to ensure two backups don't run at once
|
||||||
LOCK_FILE_TIMEOUT="" # Optional lock file wait timeout (in seconds)
|
LOCK_FILE_TIMEOUT="" # Optional lock file wait timeout (in seconds)
|
||||||
WINDOW_MANAGER="screen" # Choices: screen, tmux, RCON
|
WINDOW_MANAGER="screen" # Choices: screen, tmux, RCON
|
||||||
|
BUKKIT=false
|
||||||
|
|
||||||
# Other Variables (do not modify)
|
# Other Variables (do not modify)
|
||||||
DATE_FORMAT="%F_%H-%M-%S"
|
DATE_FORMAT="%F_%H-%M-%S"
|
||||||
|
@ -67,6 +68,7 @@ while getopts 'a:cd:e:f:hi:l:m:o:p:qr:s:t:u:vw:' FLAG; do
|
||||||
echo "-u Lock file timeout seconds (empty = unlimited)"
|
echo "-u Lock file timeout seconds (empty = unlimited)"
|
||||||
echo "-v Verbose mode"
|
echo "-v Verbose mode"
|
||||||
echo "-w Window manager: screen (default), tmux, RCON"
|
echo "-w Window manager: screen (default), tmux, RCON"
|
||||||
|
echo "-x Bukkit-style server backup mode (world files are split by dimension)"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
i) SERVER_WORLD=$OPTARG ;;
|
i) SERVER_WORLD=$OPTARG ;;
|
||||||
|
@ -81,6 +83,7 @@ while getopts 'a:cd:e:f:hi:l:m:o:p:qr:s:t:u:vw:' FLAG; do
|
||||||
u) LOCK_FILE_TIMEOUT=$OPTARG ;;
|
u) LOCK_FILE_TIMEOUT=$OPTARG ;;
|
||||||
v) DEBUG=true ;;
|
v) DEBUG=true ;;
|
||||||
w) WINDOW_MANAGER=$OPTARG ;;
|
w) WINDOW_MANAGER=$OPTARG ;;
|
||||||
|
x) BUKKIT=true ;;
|
||||||
*) log-fatal "Invalid option -$FLAG"; exit 1 ;;
|
*) log-fatal "Invalid option -$FLAG"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -476,6 +479,18 @@ clean-up () {
|
||||||
trap "clean-up" 2
|
trap "clean-up" 2
|
||||||
|
|
||||||
do-backup () {
|
do-backup () {
|
||||||
|
# set bukkit world paths if this is a bukkit server
|
||||||
|
if "$BUKKIT"; then
|
||||||
|
WORLD_PARENT_DIR=$(dirname "$SERVER_WORLD")
|
||||||
|
|
||||||
|
# overwrite SERVER_WORLD so that restic gets all 3 dirs
|
||||||
|
SERVER_WORLD="$SERVER_WORLD"\ "$SERVER_WORLD"_nether\ "$SERVER_WORLD"_the_end
|
||||||
|
TAR_ARGS=$(basename -a "$SERVER_WORLD")
|
||||||
|
else
|
||||||
|
# no bukkit--retain previous functionality
|
||||||
|
WORLD_PARENT_DIR="$SERVER_WORLD"
|
||||||
|
TAR_ARGS="."
|
||||||
|
fi
|
||||||
# Notify players of start
|
# Notify players of start
|
||||||
message-players "Starting backup..." "$ARCHIVE_FILE_NAME"
|
message-players "Starting backup..." "$ARCHIVE_FILE_NAME"
|
||||||
|
|
||||||
|
@ -491,10 +506,10 @@ do-backup () {
|
||||||
|
|
||||||
case $COMPRESSION_ALGORITHM in
|
case $COMPRESSION_ALGORITHM in
|
||||||
# No compression
|
# No compression
|
||||||
"") tar -cf "$ARCHIVE_PATH" -C "$SERVER_WORLD" .
|
"") tar -cf "$ARCHIVE_PATH" -C "$WORLD_PARENT_DIR" "$TAR_ARGS"
|
||||||
;;
|
;;
|
||||||
# With compression
|
# With compression
|
||||||
*) tar -cf - -C "$SERVER_WORLD" . | $COMPRESSION_ALGORITHM -cv -"$COMPRESSION_LEVEL" - > "$ARCHIVE_PATH" 2>> /dev/null
|
*) tar -cf - -C "$WORLD_PARENT_DIR" "$TAR_ARGS" | $COMPRESSION_ALGORITHM -cv -"$COMPRESSION_LEVEL" - > "$ARCHIVE_PATH" 2>> /dev/null
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
EXIT_CODES=("${PIPESTATUS[@]}")
|
EXIT_CODES=("${PIPESTATUS[@]}")
|
||||||
|
|
Loading…
Add table
Reference in a new issue