From c7d19c59e7e4384b887d9a8156c77d26e9e95ff5 Mon Sep 17 00:00:00 2001 From: seoseonyu Date: Wed, 31 Jan 2024 23:01:00 +0900 Subject: [PATCH 01/29] Update Dockerfile and add restore.sh script --- Dockerfile | 13 +++-- scripts/restore.sh | 123 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 scripts/restore.sh diff --git a/Dockerfile b/Dockerfile index acaf6c779..14f089538 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,10 +19,10 @@ ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0. SUPERCRONIC_SHA1SUM=cd48d45c4b10f3f0bfdd3a57d054cd05ac96812b RUN wget -q "$SUPERCRONIC_URL" \ - && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ - && chmod +x "$SUPERCRONIC" \ - && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ - && ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic + && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ + && chmod +x "$SUPERCRONIC" \ + && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ + && ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic ENV PORT= \ PUID=1000 \ @@ -52,6 +52,11 @@ RUN chmod +x /home/steam/server/init.sh /home/steam/server/start.sh /home/steam/ mv /home/steam/server/backup.sh /usr/local/bin/backup && \ mv /home/steam/server/update.sh /usr/local/bin/update +RUN chmod +x /home/steam/server/init.sh /home/steam/server/start.sh /home/steam/server/backup.sh /home/steam/server/update.sh /home/steam/server/restore.sh && \ + mv /home/steam/server/backup.sh /usr/local/bin/backup && \ + mv /home/steam/server/update.sh /usr/local/bin/update && \ + mv /home/steam/server/restore.sh /usr/local/bin/restore + WORKDIR /home/steam/server HEALTHCHECK --start-period=5m \ diff --git a/scripts/restore.sh b/scripts/restore.sh new file mode 100644 index 000000000..d1f513e03 --- /dev/null +++ b/scripts/restore.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +# Backup file directory path +BACKUP_DIRECTORY_PATH="/palworld/backups" + +# Resotre path +RESTORE_PATH="/palworld/Pal" + +term_error_handler() { + echo "An error occurred during server shutdown." + exit 1 +} + +term_handler() { + trap 'term_error_handler' ERR + + printf "\e[0;32m*****SHUTDOWN SERVER*****\e[0m\n" + if [ "${RCON_ENABLED}" = true ]; then + rcon-cli save + rcon-cli "shutdown 1" + else + kill -SIGTERM "$(pidof PalServer-Linux)" + fi + # 프로세스가 종료될 때까지 대기 + tail --pid="$(pidof PalServer-Linux)" -f 2>/dev/null + + printf "\e[0;32mShutdown complete.\e[0m\n" + trap - ERR +} + +restore_error_handler() { + printf "\033[0;31mAn error occurred during restore.\033[0m\n" + if [ -d "./tmp_save/Saved" ]; then + read -p "I have a backup before recovery can proceed. Do you want to recovery it? (y/n): " RUN_ANSWER + if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then + rm -rf "$RESTORE_PATH/Saved" + mv "./tmp_save/Saved" "$RESTORE_PATH" + printf "\e[0;32mRecovery complete.\e[0m\n" + fi + fi + + rm -rf "./tmp" + rm -rf "./tmp_save" + + exit 1 +} + +start_restore() { + trap 'restore_error_handler' ERR + # Shutdown server + # term_handler + printf "\e[0;32m*****START RESTORE*****\e[0m\n" + + # Recheck the backup file + if [ -f "$BACKUP_DIRECTORY_PATH/$FILE_NAME" ]; then + ls + # Copy the save file before restore + if [ -d "$RESTORE_PATH/Saved" ]; then + echo "Saves the current state before the restore proceeds." + rm -rf "./tmp_save" + mkdir -p "./tmp_save" + \cp -rf "$RESTORE_PATH/Saved" "./tmp_save/Saved" + + while [ ! -d "./tmp_save/Saved" ]; do + sleep 1 + done + + printf "\e[0;32mSave complete.\e[0m\n" + fi + + # Create tmp directory + rm -rf "./tmp" + mkdir -p "./tmp" + + # Decompress the backup file in tmp directory + tar -zxvf "$BACKUP_DIRECTORY_PATH/$FILE_NAME" -C "./tmp" + + # Move the backup file to the restore directory + \cp -rf -f "./tmp/Saved/" "$RESTORE_PATH" + + # Remove tmp directory + rm -rf "./tmp" + rm -rf "./tmp_save" + + printf "\e[0;32mRestore complete!!!! Please restart the Docker container\e[0m\n" + + exit 0 + else + echo "The selected backup file does not exist." + exit 1 + fi + + trap - ERR +} + +# Go to backup file directory +cd "$BACKUP_DIRECTORY_PATH" + +# Show up backup list +echo "Backup List:" +select FILE_NAME in *; do + if [ -n "$FILE_NAME" ]; then + echo "Selected backup: $FILE_NAME" + break + else + echo "Invalid selection. Please try again." + fi +done + +if [ -f "$BACKUP_DIRECTORY_PATH/$FILE_NAME" ]; then + echo "Do you want to continue with the command?" + read -p "When you run it, the server will be stopped and the recovery will proceed. (y/n): " RUN_ANSWER + if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then + printf "\e[0;32m*****STARTING PROCESS*****\e[0m\n" + start_restore + else + echo "Abort the recovery." + exit 1 + fi +else + echo "The selected backup file does not exist." + exit 1 +fi From df19ef4991de971054b9cf331c1159eab7b2462a Mon Sep 17 00:00:00 2001 From: seoseonyu Date: Wed, 31 Jan 2024 23:01:11 +0900 Subject: [PATCH 02/29] Add restore instructions to README.md --- README.md | 13 +++++++++++++ docs/kr/README.md | 15 ++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d4caee0d..051f0fe0d 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,19 @@ This will create a backup at `/palworld/backups/` The server will run a save before the backup if rcon is enabled. +## Restore a backup + +To restore a backup, use the command: + +```bash +docker exec palworld-server restore +``` + +The container must be restarted after the recovery progresses. + +> [!IMPORTANT] +> It is recommended that RCON is enabled for safe recovery. + ## Configuring Automatic Backups with Cron The server is automatically backed up everynight at midnight according to the timezone set with TZ diff --git a/docs/kr/README.md b/docs/kr/README.md index 80f96bcae..c7fd93345 100644 --- a/docs/kr/README.md +++ b/docs/kr/README.md @@ -188,7 +188,7 @@ docker exec -it palworld-server rcon-cli ## 백업 만들기 -현재 시점의 게임 세이브 백업을 생성하려면 다음 명령을 사용합니다. +현재 시점의 게임 세이브 백업을 생성하려면 다음 명령을 사용합니다: ```bash docker exec palworld-server backup @@ -198,6 +198,19 @@ docker exec palworld-server backup rcon이 활성화된 경우 서버는 백업 전에 저장을 실행합니다. +## 백업 파일 복원 하기 + +백업을 복원하려면 다음 명령을 사용합니다: + +```bash +docker exec palworld-server restore +``` + +복구가 진행된 후 컨테이너를 다시 시작해야 합니다. + +> [!IMPORTANT] +> 안전한 복구를 위해 RCON을 활성화하는 것을 권장합니다. + ## 서버 설정 편집 ### 환경 변수 사용 설정 From 19e1da1c3a33917af78b0bd0215b37753c06ff5a Mon Sep 17 00:00:00 2001 From: seoseonyu Date: Wed, 31 Jan 2024 23:15:03 +0900 Subject: [PATCH 03/29] Fixes invalid code modifications and shell script lint fix --- Dockerfile | 3 --- scripts/restore.sh | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 14f089538..7e7597f5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,9 +48,6 @@ ENV PORT= \ AUTO_UPDATE_WARN_MINUTES=30 COPY ./scripts/* /home/steam/server/ -RUN chmod +x /home/steam/server/init.sh /home/steam/server/start.sh /home/steam/server/backup.sh /home/steam/server/update.sh && \ - mv /home/steam/server/backup.sh /usr/local/bin/backup && \ - mv /home/steam/server/update.sh /usr/local/bin/update RUN chmod +x /home/steam/server/init.sh /home/steam/server/start.sh /home/steam/server/backup.sh /home/steam/server/update.sh /home/steam/server/restore.sh && \ mv /home/steam/server/backup.sh /usr/local/bin/backup && \ diff --git a/scripts/restore.sh b/scripts/restore.sh index d1f513e03..3dfd17862 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -31,7 +31,7 @@ term_handler() { restore_error_handler() { printf "\033[0;31mAn error occurred during restore.\033[0m\n" if [ -d "./tmp_save/Saved" ]; then - read -p "I have a backup before recovery can proceed. Do you want to recovery it? (y/n): " RUN_ANSWER + read -rp "I have a backup before recovery can proceed. Do you want to recovery it? (y/n): " RUN_ANSWER if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then rm -rf "$RESTORE_PATH/Saved" mv "./tmp_save/Saved" "$RESTORE_PATH" @@ -109,7 +109,7 @@ done if [ -f "$BACKUP_DIRECTORY_PATH/$FILE_NAME" ]; then echo "Do you want to continue with the command?" - read -p "When you run it, the server will be stopped and the recovery will proceed. (y/n): " RUN_ANSWER + read -rp "When you run it, the server will be stopped and the recovery will proceed. (y/n): " RUN_ANSWER if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then printf "\e[0;32m*****STARTING PROCESS*****\e[0m\n" start_restore From 2a444eb40e93eab03511d9ae2fe1e0b1d6e59eec Mon Sep 17 00:00:00 2001 From: seoseonyu Date: Thu, 1 Feb 2024 00:04:39 +0900 Subject: [PATCH 04/29] Change restore command description in README.md --- README.md | 2 +- docs/kr/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 051f0fe0d..eb71c81eb 100644 --- a/README.md +++ b/README.md @@ -258,7 +258,7 @@ docker exec palworld-server restore The container must be restarted after the recovery progresses. > [!IMPORTANT] -> It is recommended that RCON is enabled for safe recovery. +> The `RCON_ENABLED` environment variable must be `true` to use this command. ## Configuring Automatic Backups with Cron diff --git a/docs/kr/README.md b/docs/kr/README.md index c7fd93345..796c2c284 100644 --- a/docs/kr/README.md +++ b/docs/kr/README.md @@ -209,7 +209,7 @@ docker exec palworld-server restore 복구가 진행된 후 컨테이너를 다시 시작해야 합니다. > [!IMPORTANT] -> 안전한 복구를 위해 RCON을 활성화하는 것을 권장합니다. +> 복원 명령어를 사용하려면 `RCON_ENABLED` 환경 변수가 `true`여야 합니다. ## 서버 설정 편집 From 53ad25035a39ec5404db6a72280e9966d6ba8b4a Mon Sep 17 00:00:00 2001 From: seoseonyu Date: Thu, 1 Feb 2024 00:04:55 +0900 Subject: [PATCH 05/29] fix restore.sh --- scripts/restore.sh | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index 3dfd17862..3558b8212 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -16,14 +16,11 @@ term_handler() { printf "\e[0;32m*****SHUTDOWN SERVER*****\e[0m\n" if [ "${RCON_ENABLED}" = true ]; then - rcon-cli save - rcon-cli "shutdown 1" + rcon-cli -c /home/steam/server/rcon.yaml save + rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" else - kill -SIGTERM "$(pidof PalServer-Linux)" + echo "RCON is not enabled. Please enable RCON to use this feature." fi - # 프로세스가 종료될 때까지 대기 - tail --pid="$(pidof PalServer-Linux)" -f 2>/dev/null - printf "\e[0;32mShutdown complete.\e[0m\n" trap - ERR } @@ -48,11 +45,11 @@ restore_error_handler() { start_restore() { trap 'restore_error_handler' ERR # Shutdown server - # term_handler + term_handler printf "\e[0;32m*****START RESTORE*****\e[0m\n" # Recheck the backup file - if [ -f "$BACKUP_DIRECTORY_PATH/$FILE_NAME" ]; then + if [ -f "$BACKUP_FILE" ]; then ls # Copy the save file before restore if [ -d "$RESTORE_PATH/Saved" ]; then @@ -73,7 +70,7 @@ start_restore() { mkdir -p "./tmp" # Decompress the backup file in tmp directory - tar -zxvf "$BACKUP_DIRECTORY_PATH/$FILE_NAME" -C "./tmp" + tar -zxvf "$BACKUP_FILE" -C "./tmp" # Move the backup file to the restore directory \cp -rf -f "./tmp/Saved/" "$RESTORE_PATH" @@ -93,21 +90,23 @@ start_restore() { trap - ERR } -# Go to backup file directory -cd "$BACKUP_DIRECTORY_PATH" +if [ "${RCON_ENABLED}" != true ]; then + echo "RCON is not enabled. Please enable RCON to use this feature." + exit 1 +fi # Show up backup list echo "Backup List:" -select FILE_NAME in *; do - if [ -n "$FILE_NAME" ]; then - echo "Selected backup: $FILE_NAME" +select BACKUP_FILE in "$BACKUP_DIRECTORY_PATH"/*; do + if [ -n "$BACKUP_FILE" ]; then + echo "Selected backup: $BACKUP_FILE" break else echo "Invalid selection. Please try again." fi done -if [ -f "$BACKUP_DIRECTORY_PATH/$FILE_NAME" ]; then +if [ -f "$BACKUP_FILE" ]; then echo "Do you want to continue with the command?" read -rp "When you run it, the server will be stopped and the recovery will proceed. (y/n): " RUN_ANSWER if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then @@ -120,4 +119,4 @@ if [ -f "$BACKUP_DIRECTORY_PATH/$FILE_NAME" ]; then else echo "The selected backup file does not exist." exit 1 -fi +fi \ No newline at end of file From 71eba36ff0685b44e39ec6b964f2c84d57f671b2 Mon Sep 17 00:00:00 2001 From: seoseonyu Date: Thu, 1 Feb 2024 00:17:43 +0900 Subject: [PATCH 06/29] Remove unnecessary functions --- scripts/restore.sh | 119 +++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 63 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index 3558b8212..6cacee033 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -11,20 +11,6 @@ term_error_handler() { exit 1 } -term_handler() { - trap 'term_error_handler' ERR - - printf "\e[0;32m*****SHUTDOWN SERVER*****\e[0m\n" - if [ "${RCON_ENABLED}" = true ]; then - rcon-cli -c /home/steam/server/rcon.yaml save - rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" - else - echo "RCON is not enabled. Please enable RCON to use this feature." - fi - printf "\e[0;32mShutdown complete.\e[0m\n" - trap - ERR -} - restore_error_handler() { printf "\033[0;31mAn error occurred during restore.\033[0m\n" if [ -d "./tmp_save/Saved" ]; then @@ -42,54 +28,6 @@ restore_error_handler() { exit 1 } -start_restore() { - trap 'restore_error_handler' ERR - # Shutdown server - term_handler - printf "\e[0;32m*****START RESTORE*****\e[0m\n" - - # Recheck the backup file - if [ -f "$BACKUP_FILE" ]; then - ls - # Copy the save file before restore - if [ -d "$RESTORE_PATH/Saved" ]; then - echo "Saves the current state before the restore proceeds." - rm -rf "./tmp_save" - mkdir -p "./tmp_save" - \cp -rf "$RESTORE_PATH/Saved" "./tmp_save/Saved" - - while [ ! -d "./tmp_save/Saved" ]; do - sleep 1 - done - - printf "\e[0;32mSave complete.\e[0m\n" - fi - - # Create tmp directory - rm -rf "./tmp" - mkdir -p "./tmp" - - # Decompress the backup file in tmp directory - tar -zxvf "$BACKUP_FILE" -C "./tmp" - - # Move the backup file to the restore directory - \cp -rf -f "./tmp/Saved/" "$RESTORE_PATH" - - # Remove tmp directory - rm -rf "./tmp" - rm -rf "./tmp_save" - - printf "\e[0;32mRestore complete!!!! Please restart the Docker container\e[0m\n" - - exit 0 - else - echo "The selected backup file does not exist." - exit 1 - fi - - trap - ERR -} - if [ "${RCON_ENABLED}" != true ]; then echo "RCON is not enabled. Please enable RCON to use this feature." exit 1 @@ -111,7 +49,62 @@ if [ -f "$BACKUP_FILE" ]; then read -rp "When you run it, the server will be stopped and the recovery will proceed. (y/n): " RUN_ANSWER if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then printf "\e[0;32m*****STARTING PROCESS*****\e[0m\n" - start_restore + # Shutdown server + trap 'term_error_handler' ERR + + printf "\e[0;32m*****SHUTDOWN SERVER*****\e[0m\n" + if [ "${RCON_ENABLED}" = true ]; then + rcon-cli -c /home/steam/server/rcon.yaml save + rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" + else + echo "RCON is not enabled. Please enable RCON to use this feature." + fi + printf "\e[0;32mShutdown complete.\e[0m\n" + + trap - ERR + + trap 'restore_error_handler' ERR + + printf "\e[0;32m*****START RESTORE*****\e[0m\n" + + # Recheck the backup file + if [ -f "$BACKUP_FILE" ]; then + # Copy the save file before restore + if [ -d "$RESTORE_PATH/Saved" ]; then + echo "Saves the current state before the restore proceeds." + rm -rf "./tmp_save" + mkdir -p "./tmp_save" + \cp -rf "$RESTORE_PATH/Saved" "./tmp_save/Saved" + + while [ ! -d "./tmp_save/Saved" ]; do + sleep 1 + done + + printf "\e[0;32mSave complete.\e[0m\n" + fi + + # Create tmp directory + rm -rf "./tmp" + mkdir -p "./tmp" + + # Decompress the backup file in tmp directory + tar -zxvf "$BACKUP_FILE" -C "./tmp" + + # Move the backup file to the restore directory + \cp -rf -f "./tmp/Saved/" "$RESTORE_PATH" + + # Remove tmp directory + rm -rf "./tmp" + rm -rf "./tmp_save" + + printf "\e[0;32mRestore complete!!!! Please restart the Docker container\e[0m\n" + + exit 0 + else + echo "The selected backup file does not exist." + exit 1 + fi + trap - ERR else echo "Abort the recovery." exit 1 From 6ec55134ced7174e421d2e05bca6d3697bb9ad65 Mon Sep 17 00:00:00 2001 From: seoseonyu Date: Thu, 1 Feb 2024 00:21:13 +0900 Subject: [PATCH 07/29] fix restore.sh unreachable code --- scripts/restore.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index 6cacee033..5ffccf6ad 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -60,7 +60,7 @@ if [ -f "$BACKUP_FILE" ]; then echo "RCON is not enabled. Please enable RCON to use this feature." fi printf "\e[0;32mShutdown complete.\e[0m\n" - + trap - ERR trap 'restore_error_handler' ERR @@ -98,13 +98,14 @@ if [ -f "$BACKUP_FILE" ]; then rm -rf "./tmp_save" printf "\e[0;32mRestore complete!!!! Please restart the Docker container\e[0m\n" - + + trap - ERR exit 0 else echo "The selected backup file does not exist." + trap - ERR exit 1 fi - trap - ERR else echo "Abort the recovery." exit 1 From d275462b617b79c113e6f2fd36cf6e980595f36f Mon Sep 17 00:00:00 2001 From: seoseonyu Date: Thu, 1 Feb 2024 00:24:36 +0900 Subject: [PATCH 08/29] Remove unnecessary codes --- scripts/restore.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index 5ffccf6ad..d24b02622 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -99,11 +99,9 @@ if [ -f "$BACKUP_FILE" ]; then printf "\e[0;32mRestore complete!!!! Please restart the Docker container\e[0m\n" - trap - ERR exit 0 else echo "The selected backup file does not exist." - trap - ERR exit 1 fi else From 6bf7c81fda000e5d2c0433d816a370cab70b102a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Thu, 1 Feb 2024 08:24:44 +0900 Subject: [PATCH 09/29] End script if `RCON` is disabled Co-authored-by: Carlos Martinez --- scripts/restore.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index d24b02622..f0f3c1ce9 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -52,12 +52,13 @@ if [ -f "$BACKUP_FILE" ]; then # Shutdown server trap 'term_error_handler' ERR - printf "\e[0;32m*****SHUTDOWN SERVER*****\e[0m\n" if [ "${RCON_ENABLED}" = true ]; then + printf "\e[0;32m*****SHUTDOWN SERVER*****\e[0m\n" rcon-cli -c /home/steam/server/rcon.yaml save rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" else - echo "RCON is not enabled. Please enable RCON to use this feature." + echo "RCON is not enabled. Please enable RCON to use this feature. Unable to restore backup." + exit 1 fi printf "\e[0;32mShutdown complete.\e[0m\n" From a2c64901d7190ac5e06296d4ae4f6d3759d12406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Thu, 1 Feb 2024 08:31:31 +0900 Subject: [PATCH 10/29] fix restore.sh spacing -> 4x --- scripts/restore.sh | 141 +++++++++++++++++++++++---------------------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index f0f3c1ce9..ab75939ab 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -6,20 +6,21 @@ BACKUP_DIRECTORY_PATH="/palworld/backups" # Resotre path RESTORE_PATH="/palworld/Pal" +# shellcheck disable=SC2317 term_error_handler() { echo "An error occurred during server shutdown." exit 1 -} +# shellcheck disable=SC2317 restore_error_handler() { printf "\033[0;31mAn error occurred during restore.\033[0m\n" if [ -d "./tmp_save/Saved" ]; then - read -rp "I have a backup before recovery can proceed. Do you want to recovery it? (y/n): " RUN_ANSWER - if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then - rm -rf "$RESTORE_PATH/Saved" - mv "./tmp_save/Saved" "$RESTORE_PATH" - printf "\e[0;32mRecovery complete.\e[0m\n" - fi + read -rp "I have a backup before recovery can proceed. Do you want to recovery it? (y/n): " RUN_ANSWER + if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then + rm -rf "$RESTORE_PATH/Saved" + mv "./tmp_save/Saved" "$RESTORE_PATH" + printf "\e[0;32mRecovery complete.\e[0m\n" + fi fi rm -rf "./tmp" @@ -29,8 +30,8 @@ restore_error_handler() { } if [ "${RCON_ENABLED}" != true ]; then - echo "RCON is not enabled. Please enable RCON to use this feature." - exit 1 + echo "RCON is not enabled. Please enable RCON to use this feature." + exit 1 fi # Show up backup list @@ -45,70 +46,70 @@ select BACKUP_FILE in "$BACKUP_DIRECTORY_PATH"/*; do done if [ -f "$BACKUP_FILE" ]; then - echo "Do you want to continue with the command?" - read -rp "When you run it, the server will be stopped and the recovery will proceed. (y/n): " RUN_ANSWER - if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then - printf "\e[0;32m*****STARTING PROCESS*****\e[0m\n" - # Shutdown server - trap 'term_error_handler' ERR - - if [ "${RCON_ENABLED}" = true ]; then - printf "\e[0;32m*****SHUTDOWN SERVER*****\e[0m\n" - rcon-cli -c /home/steam/server/rcon.yaml save - rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" + echo "Do you want to continue with the command?" + read -rp "When you run it, the server will be stopped and the recovery will proceed. (y/n): " RUN_ANSWER + if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then + printf "\e[0;32m*****STARTING PROCESS*****\e[0m\n" + # Shutdown server + trap 'term_error_handler' ERR + + if [ "${RCON_ENABLED}" = true ]; then + printf "\e[0;32m*****SHUTDOWN SERVER*****\e[0m\n" + rcon-cli -c /home/steam/server/rcon.yaml save + rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" + else + echo "RCON is not enabled. Please enable RCON to use this feature. Unable to restore backup." + exit 1 + fi + printf "\e[0;32mShutdown complete.\e[0m\n" + + trap - ERR + + trap 'restore_error_handler' ERR + + printf "\e[0;32m*****START RESTORE*****\e[0m\n" + + # Recheck the backup file + if [ -f "$BACKUP_FILE" ]; then + # Copy the save file before restore + if [ -d "$RESTORE_PATH/Saved" ]; then + echo "Saves the current state before the restore proceeds." + rm -rf "./tmp_save" + mkdir -p "./tmp_save" + \cp -rf "$RESTORE_PATH/Saved" "./tmp_save/Saved" + + while [ ! -d "./tmp_save/Saved" ]; do + sleep 1 + done + + printf "\e[0;32mSave complete.\e[0m\n" + fi + + # Create tmp directory + rm -rf "./tmp" + mkdir -p "./tmp" + + # Decompress the backup file in tmp directory + tar -zxvf "$BACKUP_FILE" -C "./tmp" + + # Move the backup file to the restore directory + \cp -rf -f "./tmp/Saved/" "$RESTORE_PATH" + + # Remove tmp directory + rm -rf "./tmp" + rm -rf "./tmp_save" + + printf "\e[0;32mRestore complete!!!! Please restart the Docker container\e[0m\n" + + exit 0 + else + echo "The selected backup file does not exist." + exit 1 + fi else - echo "RCON is not enabled. Please enable RCON to use this feature. Unable to restore backup." + echo "Abort the recovery." exit 1 fi - printf "\e[0;32mShutdown complete.\e[0m\n" - - trap - ERR - - trap 'restore_error_handler' ERR - - printf "\e[0;32m*****START RESTORE*****\e[0m\n" - - # Recheck the backup file - if [ -f "$BACKUP_FILE" ]; then - # Copy the save file before restore - if [ -d "$RESTORE_PATH/Saved" ]; then - echo "Saves the current state before the restore proceeds." - rm -rf "./tmp_save" - mkdir -p "./tmp_save" - \cp -rf "$RESTORE_PATH/Saved" "./tmp_save/Saved" - - while [ ! -d "./tmp_save/Saved" ]; do - sleep 1 - done - - printf "\e[0;32mSave complete.\e[0m\n" - fi - - # Create tmp directory - rm -rf "./tmp" - mkdir -p "./tmp" - - # Decompress the backup file in tmp directory - tar -zxvf "$BACKUP_FILE" -C "./tmp" - - # Move the backup file to the restore directory - \cp -rf -f "./tmp/Saved/" "$RESTORE_PATH" - - # Remove tmp directory - rm -rf "./tmp" - rm -rf "./tmp_save" - - printf "\e[0;32mRestore complete!!!! Please restart the Docker container\e[0m\n" - - exit 0 - else - echo "The selected backup file does not exist." - exit 1 - fi - else - echo "Abort the recovery." - exit 1 - fi else echo "The selected backup file does not exist." exit 1 From 1c8c366cb7caf812a32703b62728e0afacfcc533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Thu, 1 Feb 2024 08:34:15 +0900 Subject: [PATCH 11/29] fix restore.sh Syntax errors --- scripts/restore.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/restore.sh b/scripts/restore.sh index ab75939ab..5e26af8e1 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -10,6 +10,7 @@ RESTORE_PATH="/palworld/Pal" term_error_handler() { echo "An error occurred during server shutdown." exit 1 +} # shellcheck disable=SC2317 restore_error_handler() { From 28308a89e2111fe8748a8a60f6ffc2a2d6aa7f51 Mon Sep 17 00:00:00 2001 From: seoseonyu Date: Thu, 1 Feb 2024 23:18:10 +0900 Subject: [PATCH 12/29] Add Wait for restore to complete --- scripts/init.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/init.sh b/scripts/init.sh index 8a216c23c..d43c43d7b 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -36,3 +36,11 @@ if [ "${#backup_pids[@]}" -ne 0 ]; then tail --pid="$pid" -f 2>/dev/null done fi + +mapfile -t restore_pids < <(pgrep restore) +if [ "${#restore_pids[@]}" -ne 0 ]; then + echo "Waiting for restore to finish" + for pid in "${restore_pids[@]}"; do + tail --pid="$pid" -f 2>/dev/null + done +fi From 434ad68d6afd326f66bf66909e202d16c0956b04 Mon Sep 17 00:00:00 2001 From: seoseonyu Date: Thu, 1 Feb 2024 23:18:41 +0900 Subject: [PATCH 13/29] Add temporary save file path for restore process --- scripts/restore.sh | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index 5e26af8e1..d19500910 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -6,6 +6,9 @@ BACKUP_DIRECTORY_PATH="/palworld/backups" # Resotre path RESTORE_PATH="/palworld/Pal" +# Copy the save file before restore temporary path +TMP_SAVE_PATH="/palworld/backups/restore-"$(date +"%Y-%m-%d_%H-%M-%S") + # shellcheck disable=SC2317 term_error_handler() { echo "An error occurred during server shutdown." @@ -15,17 +18,18 @@ term_error_handler() { # shellcheck disable=SC2317 restore_error_handler() { printf "\033[0;31mAn error occurred during restore.\033[0m\n" - if [ -d "./tmp_save/Saved" ]; then + if [ -d "$TMP_SAVE_PATH/Saved" ]; then read -rp "I have a backup before recovery can proceed. Do you want to recovery it? (y/n): " RUN_ANSWER if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then rm -rf "$RESTORE_PATH/Saved" - mv "./tmp_save/Saved" "$RESTORE_PATH" + mv "$TMP_SAVE_PATH/Saved" "$RESTORE_PATH" printf "\e[0;32mRecovery complete.\e[0m\n" fi fi - rm -rf "./tmp" - rm -rf "./tmp_save" + echo "Clean up the temporary directory." + rm -rf "$TMP_PATH" + rm -rf "$TMP_SAVE_PATH" exit 1 } @@ -75,11 +79,11 @@ if [ -f "$BACKUP_FILE" ]; then # Copy the save file before restore if [ -d "$RESTORE_PATH/Saved" ]; then echo "Saves the current state before the restore proceeds." - rm -rf "./tmp_save" - mkdir -p "./tmp_save" - \cp -rf "$RESTORE_PATH/Saved" "./tmp_save/Saved" + echo "$TMP_SAVE_PATH" + mkdir -p "$TMP_SAVE_PATH" + \cp -rf "$RESTORE_PATH/Saved" "$TMP_SAVE_PATH/Saved" - while [ ! -d "./tmp_save/Saved" ]; do + while [ ! -d "$TMP_SAVE_PATH/Saved" ]; do sleep 1 done @@ -87,18 +91,19 @@ if [ -f "$BACKUP_FILE" ]; then fi # Create tmp directory - rm -rf "./tmp" - mkdir -p "./tmp" + TMP_PATH=$(mktemp -d -p "/palworld/backups") # Decompress the backup file in tmp directory - tar -zxvf "$BACKUP_FILE" -C "./tmp" + tar -zxvf "$BACKUP_FILE" -C "$TMP_PATH" # Move the backup file to the restore directory - \cp -rf -f "./tmp/Saved/" "$RESTORE_PATH" + \cp -rf -f "$TMP_PATH/Saved/" "$RESTORE_PATH" + + restore_error_handler - # Remove tmp directory - rm -rf "./tmp" - rm -rf "./tmp_save" + echo "Clean up the temporary directory." + rm -rf "$TMP_PATH" + rm -rf "$TMP_SAVE_PATH" printf "\e[0;32mRestore complete!!!! Please restart the Docker container\e[0m\n" From c8142fea8deb78de45263d1fda420ce9fd94990f Mon Sep 17 00:00:00 2001 From: seoseonyu Date: Thu, 1 Feb 2024 23:20:34 +0900 Subject: [PATCH 14/29] remove test code --- scripts/restore.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index d19500910..8123f5ca6 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -99,8 +99,6 @@ if [ -f "$BACKUP_FILE" ]; then # Move the backup file to the restore directory \cp -rf -f "$TMP_PATH/Saved/" "$RESTORE_PATH" - restore_error_handler - echo "Clean up the temporary directory." rm -rf "$TMP_PATH" rm -rf "$TMP_SAVE_PATH" From 5b8105c5a6574605886df14711d73f077cf18eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 08:13:28 +0900 Subject: [PATCH 15/29] Change the temporary folder creation code to a single line Co-authored-by: Carlos Martinez --- scripts/restore.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index 8123f5ca6..f5bdba5f9 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -28,8 +28,7 @@ restore_error_handler() { fi echo "Clean up the temporary directory." - rm -rf "$TMP_PATH" - rm -rf "$TMP_SAVE_PATH" + rm -rf "$TMP_PATH" "$TMP_SAVE_PATH" exit 1 } From e611c81c7ce2f2ecf4d655b9dc2987f0acd950e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 08:48:47 +0900 Subject: [PATCH 16/29] Change the temporary folder cleanup code to one line --- scripts/restore.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index f5bdba5f9..83013e9c1 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -99,8 +99,7 @@ if [ -f "$BACKUP_FILE" ]; then \cp -rf -f "$TMP_PATH/Saved/" "$RESTORE_PATH" echo "Clean up the temporary directory." - rm -rf "$TMP_PATH" - rm -rf "$TMP_SAVE_PATH" + rm -rf "$TMP_PATH" "$TMP_SAVE_PATH" printf "\e[0;32mRestore complete!!!! Please restart the Docker container\e[0m\n" From a54d5495ba7d12e265e04fd2bf241f4da52d3f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 08:52:36 +0900 Subject: [PATCH 17/29] Update scripts/restore.sh - Modify the backup file listup code - Sort by backup file name - Modify to show only file types in the list Co-authored-by: Carlos Martinez --- scripts/restore.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index 83013e9c1..bdd3244fc 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -40,7 +40,8 @@ fi # Show up backup list echo "Backup List:" -select BACKUP_FILE in "$BACKUP_DIRECTORY_PATH"/*; do +mapfile -t BACKUP_FILES < <(find "$BACKUP_DIRECTORY_PATH" -type f -name "*.tar.gz" | sort) +select BACKUP_FILE in "${BACKUP_FILES[@]}"; do if [ -n "$BACKUP_FILE" ]; then echo "Selected backup: $BACKUP_FILE" break From 518461c98e685f3d877e11cdcafcb5013d0d2c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 09:02:31 +0900 Subject: [PATCH 18/29] Simplify conditional statements that ask users questions and get answers --- scripts/restore.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index bdd3244fc..06f5b8caa 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -20,7 +20,7 @@ restore_error_handler() { printf "\033[0;31mAn error occurred during restore.\033[0m\n" if [ -d "$TMP_SAVE_PATH/Saved" ]; then read -rp "I have a backup before recovery can proceed. Do you want to recovery it? (y/n): " RUN_ANSWER - if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then + if [[ ${RUN_ANSWER,,} == "y" ]]; then rm -rf "$RESTORE_PATH/Saved" mv "$TMP_SAVE_PATH/Saved" "$RESTORE_PATH" printf "\e[0;32mRecovery complete.\e[0m\n" @@ -53,7 +53,7 @@ done if [ -f "$BACKUP_FILE" ]; then echo "Do you want to continue with the command?" read -rp "When you run it, the server will be stopped and the recovery will proceed. (y/n): " RUN_ANSWER - if [[ $RUN_ANSWER == "y" ]] || [[ $RUN_ANSWER == "Y" ]]; then + if [[ ${RUN_ANSWER,,} == "y" ]]; then printf "\e[0;32m*****STARTING PROCESS*****\e[0m\n" # Shutdown server trap 'term_error_handler' ERR From 6be70a7df224ffc4d26f02269266ad8e25206b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 09:31:59 +0900 Subject: [PATCH 19/29] set ownership of the temp save directory Co-authored-by: Carlos Martinez --- scripts/restore.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/restore.sh b/scripts/restore.sh index 06f5b8caa..393ed20a1 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -81,6 +81,9 @@ if [ -f "$BACKUP_FILE" ]; then echo "Saves the current state before the restore proceeds." echo "$TMP_SAVE_PATH" mkdir -p "$TMP_SAVE_PATH" + if [ "$(id -u)" -eq 0 ]; then + chown steam:steam "$TMP_SAVE_PATH" + fi \cp -rf "$RESTORE_PATH/Saved" "$TMP_SAVE_PATH/Saved" while [ ! -d "$TMP_SAVE_PATH/Saved" ]; do From 8c968eeada4e03bfa37753b504f15c97a267e1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 09:32:31 +0900 Subject: [PATCH 20/29] set ownership of the restore work temp directory Co-authored-by: Carlos Martinez --- scripts/restore.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/restore.sh b/scripts/restore.sh index 393ed20a1..da4f5a219 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -95,6 +95,9 @@ if [ -f "$BACKUP_FILE" ]; then # Create tmp directory TMP_PATH=$(mktemp -d -p "/palworld/backups") + if [ "$(id -u)" -eq 0 ]; then + chown steam:steam "$TMP_PATH" + fi # Decompress the backup file in tmp directory tar -zxvf "$BACKUP_FILE" -C "$TMP_PATH" From cdbb2c641e956bf4e7ce0c6eb573edba6fc70806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 09:34:29 +0900 Subject: [PATCH 21/29] Update restore important comment on README.md Co-authored-by: Carlos Martinez --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dc7685871..9e8d81abd 100644 --- a/README.md +++ b/README.md @@ -255,10 +255,12 @@ To restore a backup, use the command: docker exec palworld-server restore ``` -The container must be restarted after the recovery progresses. - +The `RCON_ENABLED` environment variable must be set to `true` to use this command. > [!IMPORTANT] -> The `RCON_ENABLED` environment variable must be `true` to use this command. +> If docker restart is not set to policy `always` or `unless-stopped` then the server will shutdown and will need to be +> manually restarted. +> +> The example docker run command and docker compose file in [How to Use](#how-to-use) already uses the needed policy ## Configuring Automatic Backups with Cron From 5116dd5345a35142a1a0b28fc4bea98f975b3379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 09:48:33 +0900 Subject: [PATCH 22/29] Update restore description in KR README.md --- docs/kr/README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/kr/README.md b/docs/kr/README.md index 631391232..2ab759774 100644 --- a/docs/kr/README.md +++ b/docs/kr/README.md @@ -13,14 +13,14 @@ [English](/README.md) | [한국어](/docs/kr/README.md) | [简体中文](/docs/zh-CN/README.md) -> [!Tip] +> [!TIP] > 어떻게 시작해야 할지 모르시나요? [제가 작성한 이 가이드](https://tice.tips/containerization/palworld-server-docker/)를 확인해 보세요 [Palworld](https://store.steampowered.com/app/1623730/Palworld/) 전용 서버 호스팅을 시작하는 데 도움이 되는 Docker 컨테이너입니다. 이 도커 컨테이너는 테스트되었으며 Linux(Ubuntu/Debian), Windows 10 및 macOS (Apple Silicon 포함) 모두에서 작동합니다. -> [!Important] +> [!IMPORTANT] > 현재 Xbox Gamepass/Xbox 콘솔 플레이어는 전용 서버에 참여할 수 없습니다. > > 초대 코드를 통해 다른 플레이어들과 함께 게임을 즐길 수 있으며, 게임은 최대 4명의 플레이어로 제한됩니다. @@ -198,7 +198,7 @@ docker exec palworld-server backup rcon이 활성화된 경우 서버는 백업 전에 저장을 실행합니다. -## 백업 파일 복원 하기 +## 백업 복원 하기 백업을 복원하려면 다음 명령을 사용합니다: @@ -206,16 +206,18 @@ rcon이 활성화된 경우 서버는 백업 전에 저장을 실행합니다. docker exec palworld-server restore ``` -복구가 진행된 후 컨테이너를 다시 시작해야 합니다. +복원 명령어를 사용하려면 `RCON_ENABLED` 환경 변수가 `true`여야 합니다. > [!IMPORTANT] -> 복원 명령어를 사용하려면 `RCON_ENABLED` 환경 변수가 `true`여야 합니다. +> 도커 `restart` 정책이 `always` 또는 `unless-stopped`로 설정 되어있지 않다면 복원 이후 컨테이너가 종료되므로 수동으로 재시작 해야 합니다. +> +> [사용하기](#사용하기)에서 제공된 Docker 실행 명령어와 Docker Compose 파일 예시는 이미 필요한 정책을 적용하고 있습니다. ## 서버 설정 편집 ### 환경 변수 사용 설정 -> [!Important] +> [!IMPORTANT] > > 게임이 아직 베타버전이므로 이러한 환경 변수/설정은 변경될 수 있습니다 @@ -289,7 +291,7 @@ docker exec palworld-server restore 서버 설정에 대한 자세한 설명 목록을 보려면 다음을 참조하세요: [shockbyte](https://shockbyte.com/billing/knowledgebase/1189/How-to-Configure-your-Palworld-server.html) -> [!Tip] +> [!TIP] > 만약 `/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini` 파일 내부가 비어 있으면, > 파일을 삭제하고 서버를 다시 시작하면 콘텐츠가 포함된 새 파일이 생성됩니다. From 3955f10658edfe228fcc23be9f005876d571c300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 09:50:39 +0900 Subject: [PATCH 23/29] Fix README.md lint --- docs/kr/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/kr/README.md b/docs/kr/README.md index 2ab759774..ea85f0e76 100644 --- a/docs/kr/README.md +++ b/docs/kr/README.md @@ -209,7 +209,7 @@ docker exec palworld-server restore 복원 명령어를 사용하려면 `RCON_ENABLED` 환경 변수가 `true`여야 합니다. > [!IMPORTANT] -> 도커 `restart` 정책이 `always` 또는 `unless-stopped`로 설정 되어있지 않다면 복원 이후 컨테이너가 종료되므로 수동으로 재시작 해야 합니다. +> 도커 `restart` 정책이 `always` 또는 `unless-stopped`로 설정 되어있지 않다면 복원 이후 컨테이너가 종료되므로 수동으로 재시작 해야 합니다. > > [사용하기](#사용하기)에서 제공된 Docker 실행 명령어와 Docker Compose 파일 예시는 이미 필요한 정책을 적용하고 있습니다. From 01ea9af9590eb4bbdff7e331dfd2b8f7b8813768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 10:58:57 +0900 Subject: [PATCH 24/29] Update restore command in README.md Co-authored-by: Carlos Martinez --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e8d81abd..44cc3aaa5 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ The server will run a save before the backup if rcon is enabled. To restore a backup, use the command: ```bash -docker exec palworld-server restore +docker exec -i palworld-server restore ``` The `RCON_ENABLED` environment variable must be set to `true` to use this command. From 5f2ae3b8569373a1d72e1aecbf12a68a446777eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 10:59:12 +0900 Subject: [PATCH 25/29] Update restore command in docs/kr/README.md Co-authored-by: Carlos Martinez --- docs/kr/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/kr/README.md b/docs/kr/README.md index ea85f0e76..eae232ade 100644 --- a/docs/kr/README.md +++ b/docs/kr/README.md @@ -203,7 +203,7 @@ rcon이 활성화된 경우 서버는 백업 전에 저장을 실행합니다. 백업을 복원하려면 다음 명령을 사용합니다: ```bash -docker exec palworld-server restore +docker exec -i palworld-server restore ``` 복원 명령어를 사용하려면 `RCON_ENABLED` 환경 변수가 `true`여야 합니다. From 902df3464f81e036f979adf4cf21bf91593798c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 14:28:54 +0900 Subject: [PATCH 26/29] Update restore description in README.md Co-authored-by: Carlos Martinez --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44cc3aaa5..8f8c25ca0 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ The server will run a save before the backup if rcon is enabled. To restore a backup, use the command: ```bash -docker exec -i palworld-server restore +docker exec -it palworld-server restore ``` The `RCON_ENABLED` environment variable must be set to `true` to use this command. From f6bc3672c107872e63003b46d53385e0968a18fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 14:29:08 +0900 Subject: [PATCH 27/29] Update restore description in docs/kr README.md Co-authored-by: Carlos Martinez --- docs/kr/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/kr/README.md b/docs/kr/README.md index eae232ade..a9b0dadd6 100644 --- a/docs/kr/README.md +++ b/docs/kr/README.md @@ -203,7 +203,7 @@ rcon이 활성화된 경우 서버는 백업 전에 저장을 실행합니다. 백업을 복원하려면 다음 명령을 사용합니다: ```bash -docker exec -i palworld-server restore +docker exec -it palworld-server restore ``` 복원 명령어를 사용하려면 `RCON_ENABLED` 환경 변수가 `true`여야 합니다. From a8a8c858f4f23235393961c154de1242aa146383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 09:36:29 +0000 Subject: [PATCH 28/29] Add disclaimer in restore command --- scripts/restore.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index da4f5a219..e0f287273 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -51,7 +51,8 @@ select BACKUP_FILE in "${BACKUP_FILES[@]}"; do done if [ -f "$BACKUP_FILE" ]; then - echo "Do you want to continue with the command?" + printf "\033[0;31mThis script has been designed to help you restore; however, I am not responsible for any data loss. It is recommended that you create a backup beforehand, and in the event of script failure, be prepared to restore it manually.\033[0m\n" + echo "Do you understand the above and would you like to proceed with this command?" read -rp "When you run it, the server will be stopped and the recovery will proceed. (y/n): " RUN_ANSWER if [[ ${RUN_ANSWER,,} == "y" ]]; then printf "\e[0;32m*****STARTING PROCESS*****\e[0m\n" From f301c0babc7f4736aa5b3c469c5609f7e97897f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=EA=B8=88=ED=95=84?= Date: Fri, 2 Feb 2024 09:44:53 +0000 Subject: [PATCH 29/29] Change restore descript title in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3229a4628..cf2ab5af5 100644 --- a/README.md +++ b/README.md @@ -245,9 +245,9 @@ This will create a backup at `/palworld/backups/` The server will run a save before the backup if rcon is enabled. -## Restore a backup +## Restore from a backup -To restore a backup, use the command: +To restore from a backup, use the command: ```bash docker exec -it palworld-server restore