-
-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add restore command #244
Add restore command #244
Conversation
We'll work on a fix for that error. |
Resolved all Shell - Lint warnings except for functions for error handling. In order to give you the option to recover your backed up files before proceeding with the recovery by executing a handling function to detect errors if they occur during the recovery, the Error handling functions are required. The code I'm doing that generates the warning is executed when an execution error occurs via a trap. What do you think about this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You seem to be mixing 2x and 4x spacing for indentation. I would recommend using 4x spacing indentation as init.sh, start.sh, dockerfile, and update.sh, use 4x.
Backup.sh is the only one that uses 8x and docker-compose.yml is the only one that uses 3x. Don't think anyone wants to be git blamed to fix docker-compose.yml
Thanks for the suggestion. We'll take your suggestion into consideration and make changes. |
The container stops when I believe running the restore command leads to a race since the restore must finish during limited window in which the server has shutdown but |
Co-authored-by: Carlos Martinez <[email protected]>
Hmm... When I ran several tests, the restore went fine. rcon-cli -c /home/steam/server/rcon.yaml save
rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" Are you saying that if this command is executed, the recovery should happen within the container's shutdown latency? The docker in our test environment uses i will test this separately by removing the |
Yes it must happen within the shutdown period however there's no way to know the size of the shutdown period. There is a non-zero amount of time between Also looking at the script again it doesn't look like it actual waits for the server to stop. rcon-cli exits almost instantly. To prevent this you'd want to add this after the rcon |
Thanks for the feedback. I will do some more testing on this and think of a workaround. I can't fix it right now because I'm at work. 😭 |
Realizing the issue also exists for backups I made this PR #248. Also |
As suggested by @Dashboy1998, I removed the As per his suggestion, I added code to
We ran the above tests and confirmed that the container waits for termination and the game is restored to the point of view of the We fixed the creation location of the temporary directory used for restoration to |
Co-authored-by: Carlos Martinez <[email protected]>
- 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 <[email protected]>
Co-authored-by: Carlos Martinez <[email protected]>
Co-authored-by: Carlos Martinez <[email protected]>
Co-authored-by: Carlos Martinez <[email protected]>
Fixed for suggestions |
Co-authored-by: Carlos Martinez <[email protected]>
Co-authored-by: Carlos Martinez <[email protected]>
Co-authored-by: Carlos Martinez <[email protected]>
Co-authored-by: Carlos Martinez <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests
Ran store with: docker exec -it palworld-server restore
, note the -it
Created a large file for testing fallocate -l 10G palworld/Pal/Saved/deleteme
Created a backup I used to restore
-
With rcon=true, restored a backup from backups/. Restored as expected
-
With rcon=true, restored a backup from backups/subfolder/. Restored as expected
-
Tried to restore with RCON=false, provided message and exited as expected
RCON is not enabled. Please enable RCON to use this feature.
-
With rcon=true I deleted rcon.yaml to test
term_error_handler
, it triggered as expected*****STARTING PROCESS***** *****SHUTDOWN SERVER***** cli: config: parse file: read file: open /home/steam/server/rcon.yaml: no such file or directory An error occurred during server shutdown.
-
Tried to restore an invalid backup to caught
restore_error_handler
, it triggered as expected*****START RESTORE***** Saves the current state before the restore proceeds. /palworld/backups/restore-2024-02-02_00-32-50 Save complete. gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now An error occurred during restore. I have a backup before recovery can proceed. Do you want to recovery it? (y/n): y Recovery complete. Clean up the temporary directory.
*****START RESTORE***** Saves the current state before the restore proceeds. /palworld/backups/restore-2024-02-02_00-34-40 Save complete. gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now An error occurred during restore. I have a backup before recovery can proceed. Do you want to recovery it? (y/n): n Clean up the temporary directory.
-
Issued stop to the container during restore and verified it waits until restore is finished
-
I confirmed the container does wait for the restore process to complete before stopping
-
Other noteworthly results. The server must be running in order to restore. If you stop the server while in the restore process but before the shutdown command is issued then then
term_error_handler
is caught.*****STARTING PROCESS***** *****SHUTDOWN SERVER***** cli: execute: auth: rcon: dial tcp 127.0.0.1:25575: connect: connection refused An error occurred during server shutdown.
Proposed solutions for issues
Proposed solution for 5
Use file
and grep
to verify it is a gzip file. file "${BACKUP_FILE}" | grep -q 'gzip'
While this won't fix all the restore errors it will validate that we only attempt to restore gzip files.
Mind you file
is not installed in the container.
Possible solution for 8 (Just adds more issues)
Use pgrep
to see if the server is running before running the rcon command
Having this solution would introduce a new issue where if someone attempts to restore while the server is updating then starts resulting in who knows what.
Conclusion
While I did propose solutions for 5, I think what we have here is great and works as intended. I don't see a huge need to add an additional validation check for the gzip file as the output given by the error was fairly identifiable.
You have put a lot a work into this. It is amazing. I approve these changes.
Thank you very much for your help |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seoseonyu I really appreciate the work you've put into this. And thanks @Dashboy1998 for testing it so thoroughly.
I do have 1 single request, when you start the script, please show a disclaimer with the following information:
This 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.
I do not want to be responsible for people losing their data due to unforeseen circumstances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seoseonyu Amazing work!
I haven't executed this script yet but just wanna ask, will this let me select a backup file or will it only restore the latest backup? |
It let's you select a backup. |
Add restore command
Context
restore
command to restore a backup file created using thebackup
command.README.md
(English and Korean have been written, but Chinese needs additional work)Choices
Test instructions
docker file
and tested whether it runs normally after building.We've done our own error handling and testing for all cases, but if additional testing is needed, we can do it.
Checklist before requesting a review