aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar TheMightyV <themightyv@protonmail.com> 2022-01-04 22:59:56 +0100
committerGravatar TheMightyV <themightyv@protonmail.com> 2022-01-04 22:59:56 +0100
commit8a980539a3fc71834d97394d6a457a194bce9f80 (patch)
treec33f54ee2f5433dc2b0dd3a783cd4ab6b702292c
parentcba2d63889fa3ae640d213ab2c15f99d3d941967 (diff)
downloadminecraft-server-tools-8a980539a3fc71834d97394d6a457a194bce9f80.tar.gz
fixed wrong hanling of provided backup_dir in server_restore
made more outputs with VERBOSE=0
-rw-r--r--backends/borg.sh2
-rw-r--r--backends/bup.sh2
-rw-r--r--backends/tar.sh2
-rwxr-xr-xserver.sh13
4 files changed, 9 insertions, 10 deletions
diff --git a/backends/borg.sh b/backends/borg.sh
index b8854a1..b0351a0 100644
--- a/backends/borg.sh
+++ b/backends/borg.sh
@@ -24,7 +24,7 @@ function borg_create_backup() {
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
- echo_debug "borg: starting backup to \"$backup_dir\""
+ echo "borg: backing up to \"$backup_dir\""
borg create \
"${backup_dir}::${BACKUP_NAME}_$(date +'%F_%H-%M-%S')" \
diff --git a/backends/bup.sh b/backends/bup.sh
index 50c2b86..cae36fe 100644
--- a/backends/bup.sh
+++ b/backends/bup.sh
@@ -31,7 +31,7 @@ function bup_create_backup() {
local retcode=1
for backup_dir in ${BACKUP_DIRS[*]}
do
- echo_debug "bup: backing up to \"$backup_dir\""
+ echo "bup: backing up to \"$backup_dir\""
# try to save to remote
bup -d "$(bup_local)" save -r "$backup_dir" -n "$BACKUP_NAME" "$WORLD_NAME"
local status=$?
diff --git a/backends/tar.sh b/backends/tar.sh
index 00018c6..6f7a3d6 100644
--- a/backends/tar.sh
+++ b/backends/tar.sh
@@ -25,7 +25,7 @@ function tar_create_backup() {
local retcode=1
for backup_dir in ${BACKUP_DIRS[*]}
do
- echo_debug "tar: pushing to \"$backup_dir\""
+ echo "tar: backing up to \"$backup_dir\""
# scp acts as cp for local destination directories
scp "$archname" "$backup_dir/"
status=$?
diff --git a/server.sh b/server.sh
index d68a203..af7eb1e 100755
--- a/server.sh
+++ b/server.sh
@@ -154,16 +154,17 @@ function test_backup_integrity() {
local retcode=0
for backup_dir in ${BACKUP_DIRS[*]}
do
- local serverdir="$PWD"
local tmpdir=$(mktemp -d);
# restore most recent backup to a temporary dir
- if ! server_restore "$serverdir/$backup_dir" 0 "$tmpdir" ; then
+ if ! server_restore "$backup_dir" 0 "$tmpdir" ; then
echo "Failed to get latest snapshot from \"$backup_dir\""
retcode=1
elif ! same_world "$WORLD_NAME" "$tmpdir/$WORLD_NAME" ; then
echo "Latest backup from \"$backup_dir\" differs from current world!"
retcode=1
+ else
+ echo "Backup at \"$backup_dir\" is OK"
fi
rm -r "$tmpdir"
@@ -171,10 +172,10 @@ function test_backup_integrity() {
if [ $retcode -ne 0 ] ; then
echo "Backup integrity check: FAILED"
- return 1
+ else
+ echo "Backup integrity check: OK"
fi
- echo "Backup integrity check: OK"
- return 0
+ return $retcode
}
function create_backup() {
@@ -323,8 +324,6 @@ function server_restore() {
if [ -z $backup_dir ]; then
echo "From where get the snapshot?"
backup_dir="$(choose_from "${BACKUP_DIRS[@]}")"
- else
- backup_dir=${BACKUP_DIRS[backup_dir_index]}
fi
if ! is_in "$backup_dir" "${BACKUP_DIRS[@]}" ; then
echo "No valid backup directory selected, abort"