diff --git a/scripts/backup.sh b/scripts/backup.sh index 3f7c845fd..c659f0c50 100644 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -8,6 +8,7 @@ DATE=$(date +"%Y-%m-%d_%H-%M-%S") FILE_PATH="/palworld/backups/palworld-save-${DATE}.tar.gz" cd /palworld/Pal/ || exit +echo "Creating backup" tar -zcf "$FILE_PATH" "Saved/" if [ "$(id -u)" -eq 0 ]; then diff --git a/scripts/init.sh b/scripts/init.sh index 24c3fac10..8a216c23c 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -19,7 +19,7 @@ term_handler() { else # Does not save kill -SIGTERM "$(pidof PalServer-Linux-Test)" fi - tail --pid=$killpid -f 2>/dev/null + tail --pid="$killpid" -f 2>/dev/null } trap 'term_handler' SIGTERM @@ -27,4 +27,12 @@ trap 'term_handler' SIGTERM su steam -c ./start.sh & # Process ID of su killpid="$!" -wait $killpid +wait "$killpid" + +mapfile -t backup_pids < <(pgrep backup) +if [ "${#backup_pids[@]}" -ne 0 ]; then + echo "Waiting for backup to finish" + for pid in "${backup_pids[@]}"; do + tail --pid="$pid" -f 2>/dev/null + done +fi