Skip to content

Commit

Permalink
Merge pull request thijsvanloef#378 from Luatan/restore-from-differen…
Browse files Browse the repository at this point in the history
…t-server

Wait for the server to shutdown before restoring a backup
  • Loading branch information
thijsvanloef authored Feb 14, 2024
2 parents 35ed75e + 6c71604 commit 785cf04
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scripts/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ if [ -f "$BACKUP_FILE" ]; then
echo "RCON is not enabled. Please enable RCON to use this feature. Unable to restore backup."
exit 1
fi

mapfile -t server_pids < <(pgrep PalServer-Linux-Test)
if [ "${#server_pids[@]}" -ne 0 ]; then
echo "Waiting for Palworld to exit.."
for pid in "${server_pids[@]}"; do
tail --pid="$pid" -f 2>/dev/null
done
fi
printf "\e[0;32mShutdown complete.\e[0m\n"

trap - ERR
Expand Down Expand Up @@ -103,6 +111,9 @@ if [ -f "$BACKUP_FILE" ]; then
# Decompress the backup file in tmp directory
tar -zxvf "$BACKUP_FILE" -C "$TMP_PATH"

# Make sure Saves with a different ID are removed before restoring the save
rm -rf "$RESTORE_PATH/Saved/"

# Move the backup file to the restore directory
\cp -rf -f "$TMP_PATH/Saved/" "$RESTORE_PATH"

Expand Down

0 comments on commit 785cf04

Please sign in to comment.