Skip to content

Commit

Permalink
Merge pull request #378 from Luatan/restore-from-different-server
Browse files Browse the repository at this point in the history
Wait for the server to shutdown before restoring a backup
  • Loading branch information
thijsvanloef authored Feb 14, 2024
2 parents f23eaf6 + 045c6ff commit 3aeebf6
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 3aeebf6

Please sign in to comment.