Open shinytreecko opened 3 years ago
Since you're running the server in a docker container, you probably need to expose the ports from the container to your host machine. I imagine you are already doing something like -p 25565:25565
to expose the Minecraft server, so you'll need to also do that for 25525 to expose RCON. You're correct that you should only need to go into your router settings if you need it reachable from your external IP.
docker run -p 25565:25565 -p 25525:25525 ...
If the backup script/cron is also in a docker container, then you will need to set up docker networking so that the RCON is reachable.
(Also I recommend updating the script as the current version has better error handling for the case where we get the file changed as we read it
warning.)
Gotcha I'll update the script, and do I need any other files from the github besides backup.sh? I'm thinking I might be supposed to download rcon.sh as well but there's other files you've included as well and I also don't know what the usage of rcon.sh would be.
You shouldn't need any other scripts since I've included the contents of rcon.sh
in backup.sh
Ok I figured out the issue; in order for RCON to work I needed to use my internal IP instead of localhost for the parameter I set in SCREEN_NAME. Maybe my host file is messed up idk but it doesn't matter now lol. My only issue now is I get file changed as we read it
every time the script is run. Is there a place I could do sleep(30) in the script to possibly avoid this? The world directory for one server is 12 gb and the other one is almost 3 gb so I think it could be that when the save-off command is sent, the world doesn't finish saving before the backup starts. I could be wrong but do you have any suggestions? Or if there is a way to stop me from getting a new thing from tar in my /var/mail/
Which file does it say changed? If it's level.dat
, then this might be inevitable since that gets updated every five minutes regardless of whether save-off
is triggered or not (see MC-217729).
The file changed as we read it
warning means that the archive could have inconsistencies in the files (such as one file being older than another). See tar
exit code 1. I try to prevent this with save-off
, but due to the bug I think the only other way would be to stop the server completely. I'm not sure if it's the case that save-off
causes an auto-save, but I would hope it doesn't since that would defeat its entire purpose which is to disable saving...
If you like, you could edit backup.sh
and add a sleep 30
after line 420. If it does fix your problem, then let me know and I can look into adding a delay to the original script.
So adding the sleep 30 didn't fix it, but I seem to have created another issue somehow that I don't understand. It says /var/lib/pterodactyl/volumes/backup.sh: line 162: [: : integer expression expected
. It prints this 6 different times as well as the file changed as read warning which could be unavoidable. I looked at that line in the script and it is the exact same as the one on your GitHub and I didn't change any of it. Do you know what could be causing that issue and would you like a paste of my backup.sh?
If you could provide a paste of your backup.sh
that would be helpful for debugging. I'm not sure why that line is affected by the sleep because line 162 is part of the RCON client connection code.
This is the file I changed the extension to .txt because github doesn't support .sh files, but another important thing to note is that for some reason it doesn't always make the error happen. It will show the error about every other time. I have another script running at the same time with the crontab, so I'm thinking it could be the other script conflicting with RCON running while this one is running.
Thanks for that. I'm not sure why it's intermittently occurring, but my guess is that there is some issue with the RCON. In the line that's causing the error, the script expects a number but RCON gives it something else. It's supposed to respond with the previous request ID when the password is correct and -1 otherwise.
I've pushed a change to handle this other case, but I do think there's some issue with the RCON connection if this error occurs.
In my mail file, the cronjob gave this error. There are 2 servers running on this computer and they both have the same errors but just with different ports (the one I'm showing is port 25525 with Minecraft12345 as the password and the other one uses 25575 with the same password). I allowed the ports through UFW, but didn't port forward on my router since as far as I know I would only need to do that if I gave my external IP address to the script. When the server is started in the docker container, it says "RCON running on 0.0.0.0:25525". I tried making the cronjob use 0.0.0.0:25525:Minecraft12345 but it still prints out the exact same error messages as below saying it's using localhost. I was going to try without a password but I just realized RCON doesn't work without a password. My servers are running in docker containers and all required ports are exposed.
Subject: Cron wes@wgserver /var/lib/pterodactyl/volumes/backup.sh -c -s localhost:25525:Minecraft*12345 -w$
/var/lib/pterodactyl/volumes/backup.sh: connect: Connection refused /var/lib/pterodactyl/volumes/backup.sh: line 180: /dev/tcp/localhost/25525: Connection refused ^[[0;33mWARNING:^[[0m RCON connection failed: Could not connect to localhost:25525 /var/lib/pterodactyl/volumes/backup.sh: connect: Connection refused /var/lib/pterodactyl/volumes/backup.sh: line 180: /dev/tcp/localhost/25525: Connection refused ^[[0;33mWARNING:^[[0m RCON connection failed: Could not connect to localhost:25525 tar: .: file changed as we read it ^[[0;31mFATAL:^[[0m Archive command exited with nonzero exit code 1 /var/lib/pterodactyl/volumes/backup.sh: connect: Connection refused /var/lib/pterodactyl/volumes/backup.sh: line 180: /dev/tcp/localhost/25525: Connection refused ^[[0;33mWARNING:^[[0m RCON connection failed: Could not connect to localhost:25525 /var/lib/pterodactyl/volumes/backup.sh: connect: Connection refused /var/lib/pterodactyl/volumes/backup.sh: line 180: /dev/tcp/localhost/25525: Connection refused ^[[0;33mWARNING:^[[0m RCON connection failed: Could not connect to localhost:25525 /var/lib/pterodactyl/volumes/backup.sh: connect: Connection refused /var/lib/pterodactyl/volumes/backup.sh: line 180: /dev/tcp/localhost/25525: Connection refused ^[[0;33mWARNING:^[[0m RCON connection failed: Could not connect to localhost:25525