thijsvanloef / palworld-server-docker

A Docker Container to easily run a Palworld dedicated server.
https://hub.docker.com/r/thijsvanloef/palworld-server-docker
MIT License
2.43k stars 295 forks source link

Auto Backup not functioning #283

Closed jryanearl closed 9 months ago

jryanearl commented 9 months ago

Describe the bug

Backups are not getting generated on schedule.

To Reproduce

Steps to reproduce the behavior:

Setup an instance of this container with the following environment variables:

BACKUP_ENABLED=true BACKUP_CRON_EXPRESSION="0 "

Expected behavior

Expect to have a new back up every hour.

Actual behavior

Hard to tell if it was my manual backups or not, but it's backing up once/day only.

Screenshots

Screenshot 2024-02-03 192214

OS information

Hardware information

Synology DS1821+

docker-compose.yml contents

            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "USER=steam",
                "HOMEDIR=/home/steam",
                "STEAMCMDDIR=/home/steam/steamcmd",
                "SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.29/supercronic-linux-amd64",
                "SUPERCRONIC=supercronic-linux-amd64",
                "SUPERCRONIC_SHA1SUM=cd48d45c4b10f3f0bfdd3a57d054cd05ac96812b",
                "PORT=8211",
                "PUID=1030",
                "PGID=65537",
                "PLAYERS=16",
                "MULTITHREADING=true",
                "COMMUNITY=true",
                "PUBLIC_IP=1.2.3.4",
                "PUBLIC_PORT=8211",
                "SERVER_NAME=Clan [HK] - Central Texas Pals",
                "ADMIN_PASSWORD=redacted",
                "UPDATE_ON_BOOT=true",
                "RCON_ENABLED=true",
                "RCON_PORT=25575",
                "QUERY_PORT=27015",
                "TZ=UTC",
                "SERVER_DESCRIPTION=Linux, Ryzen V1500B, 32GB RAM, 2gig fiber",
                "BACKUP_ENABLED=true",
                "BACKUP_CRON_EXPRESSION=0 * * * *",
                "REGION=NA",
                "AUTO_UPDATE_ENABLED=true",
                "AUTO_UPDATE_WARN_MINUTES=30",
                "AUTO_REBOOT_CRON_EXPRESSION=0 4 * * *",
                "AUTO_REBOOT_ENABLED=true",
                "AUTO_REBOOT_WARN_MINUTES=5",
                "BASE_CAMP_WORKER_MAXNUM=20",
                "IS_MULTIPLAY=True",
                "PAL_EGG_DEFAULT_HATCHING_TIME=12.0"
            ],

Container/Host Logs

I see this in the container logs, I'm not sure how to debug further.

./PalServer.sh -port=8211 -queryport=27015 EpicApp=PalServer -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS
INFO[2024-02-03T07:19:24Z] read crontab: /home/steam/server/crontab
FATA[2024-02-03T07:19:24Z] bad crontab line: 'bash /usr/local/bin/update' (use -debug for details)
Shutdown handler: initalize.

Nothing after startup.

Dashboy1998 commented 9 months ago

Login to the docker container docker exec -it palworld-server bash

What is the output of echo "$BACKUP_CRON_EXPRESSION“

What is the output of cat crontab

I'm thinking other characters are being added.

jryanearl commented 9 months ago

I opened a shell in the container, and found this in the crontab contents:

/home/steam/server# cat crontab
0 * * * * bash /usr/local/bin/backup
 bash /usr/local/bin/update
0 4 * * * bash /home/steam/server/auto_reboot.sh

After digging around I found the issue in start.sh:

start.sh:    echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" >> "/home/steam/server/crontab"

BACKUP_CRON_EXPRESSION is never defined or pulled from env variables.

Dashboy1998 commented 9 months ago

I opened a shell in the container, and found this in the crontab contents:

/home/steam/server# cat crontab
0 * * * * bash /usr/local/bin/backup
 bash /usr/local/bin/update
0 4 * * * bash /home/steam/server/auto_reboot.sh

Looks like BACKUP_CRON_EXPRESSION is used just fine. It's the first line in your crontab. However AUTO_UPDATE_CRON_EXPRESSION is missing in line two.

jryanearl commented 9 months ago

Good point. Let me dig in.

jryanearl commented 9 months ago

When I docker container inspect I see:

                "BACKUP_ENABLED=true",
                "BACKUP_CRON_EXPRESSION=0 * * * *",
                "REGION=NA",
                "AUTO_UPDATE_ENABLED=true",
                "AUTO_UPDATE_WARN_MINUTES=30",
                "AUTO_REBOOT_CRON_EXPRESSION=0 4 * * *",
jryanearl commented 9 months ago

Yea config is missing: AUTO_UPDATE_CRON_EXPRESSION

Dashboy1998 commented 9 months ago

Is there anything in the logs? docker compose logs

Dashboy1998 commented 9 months ago

Yea config is missing: AUTO_UPDATE_CRON_EXPRESSION

That's still strange because we define a default value for AUTO_UPDATE_CRON_EXPRESSION in the dockerfile of 0 * * * *

What is AUTO_UPDATE_CRON_EXPRESSION set to? I recommend using printenv so you can see if it's even set printenv | grep CRON

jryanearl commented 9 months ago

Thanks for the help, I had missed AUTO_UPDATE_CRON_EXPRESSION when updating the container variables. After setting this and restarting the container, I passed out and just checked this morning:

Screenshot 2024-02-04 114312

Hourly backups are now happening. Ideally there should maybe be some safety built in around this environment variable missing. Like if the variable is undefined, display a warning or exit the container to let people know. Or maybe skip adding that line altogether to the crontab the variable isn't defined.

Thank again.

Dashboy1998 commented 9 months ago

Thanks for the help, I had missed AUTO_UPDATE_CRON_EXPRESSION when updating the container variables. After setting this and restarting the container, I passed out and just checked this morning:

Screenshot 2024-02-04 114312

Hourly backups are now happening. Ideally there should maybe be some safety built in around this environment variable missing. Like if the variable is undefined, display a warning or exit the container to let people know.

Thank again.

I'm not sure how it wasn't defined for you. The default value is set in the image so the only way to make it blank should be to manually make it blank. Shouldn't be anyway to unset it unless you modify the scripts.

Checking if it exists is definitely a good idea. Maybe we can find a way to validate the expression is valid too.

koalang commented 9 months ago

I faced the same problem. Which expression actually works for automatic backups?

BACKUP_CRON_EXPRESSION or AUTO_UPDATE_CRON_EXPRESSION

I set BACKUP_ENABLED=true and BACKUP_CRON_EXPRESSION = 0 0 * and AUTO_UPDATE_ENABLED = false

but it doesn't auto backup.


`Set BACKUP_ENABLED enable or disable automatic backups (Default is enabled)

BACKUP_CRON_EXPRESSION is a cron expression, in a Cron-Expression you define an interval for when to run jobs.`

`Set AUTO_UPDATE_ENABLED enable or disable automatic backups (Default is disabled)

AUTO_UPDATE_CRON_EXPRESSION is a cron expression, in a Cron-Expression you define an interval for when to run jobs.`

thijsvanloef commented 9 months ago

@koalang I noticed you have spaces in your env vars BACKUP_CRON_EXPRESSION = 0 0 * * * AUTO_UPDATE_ENABLED = false This can malform the variables.

On my own server I tried the exact same settings as you have, but sadly was not able to reproduce, are you sure you are using the 0.21.0 image? And could you also attach your logs?

koalang commented 9 months ago

@thijsvanloef

BACKUP_CRON_EXPRESSION = 0 0 * * * AUTO_UPDATE_ENABLED = false

I'm just trying to simplify the demo, there are actually no spaces. I'm editing on my phone and maybe some of the text layout doesn't look so good


docker image ID 1c3718819112


env file

TZ=Asia/Shanghai PLAYERS=8 PORT=8211 PUID=1000 PGID=1000 MULTITHREADING=true COMMUNITY=false PUBLIC_IP= PUBLIC_PORT= SERVER_NAME=Koala's PalWorld server SERVER_DESCRIPTION=palworld-server-docker by Thijs van Loef SERVER_PASSWORD=koala ADMIN_PASSWORD=XXX UPDATE_ON_BOOT=true RCON_ENABLED=true RCON_PORT=25575 QUERY_PORT=27015 BACKUP_ENABLED=true DELETE_OLD_BACKUPS=false OLD_BACKUP_DAYS=7 BACKUP_CRON_EXPRESSION=0 0 * * * AUTO_UPDATE_ENABLED=false AUTO_UPDATE_CRON_EXPRESSION=0 * * * * AUTO_UPDATE_WARN_MINUTES=30 AUTO_REBOOT_ENABLED=true AUTO_REBOOT_WARN_MINUTES=5 AUTO_REBOOT_CRON_EXPRESSION=23 30 * * * DIFFICULTY=None DAYTIME_SPEEDRATE=1.000000 NIGHTTIME_SPEEDRATE=1.000000 EXP_RATE=1.000000 PAL_CAPTURE_RATE=1.000000 PAL_SPAWN_NUM_RATE=1.000000 PAL_DAMAGE_RATE_ATTACK=1.000000 PAL_DAMAGE_RATE_DEFENSE=1.000000 PLAYER_DAMAGE_RATE_ATTACK=1.000000 PLAYER_DAMAGE_RATE_DEFENSE=1.000000 PLAYER_STOMACH_DECREASE_RATE=1.000000 PLAYER_STAMINA_DECREASE_RATE=1.000000 PLAYER_AUTO_HP_REGEN_RATE=1.000000 PLAYER_AUTO_HP_REGEN_RATE_IN_SLEEP=1.000000 PAL_STOMACH_DECREASE_RATE=1.000000 PAL_STAMINA_DECREASE_RATE=1.000000 PAL_AUTO_HP_REGEN_RATE=1.000000 PAL_AUTO_HP_REGEN_RATE_IN_SLEEP=1.000000 BUILD_OBJECT_DAMAGE_RATE=1.000000 BUILD_OBJECT_DETERIORATION_DAMAGE_RATE=1.000000 COLLECTION_DROP_RATE=1.000000 COLLECTION_OBJECT_HP_RATE=1.000000 COLLECTION_OBJECT_RESPAWN_SPEED_RATE=1.000000 ENEMY_DROP_ITEM_RATE=1.000000 DEATH_PENALTY=All ENABLE_PLAYER_TO_PLAYER_DAMAGE=False ENABLE_FRIENDLY_FIRE=False ENABLE_INVADER_ENEMY=True ACTIVE_UNKO=False ENABLE_AIM_ASSIST_PAD=True ENABLE_AIM_ASSIST_KEYBOARD=False DROP_ITEM_MAX_NUM=3000 DROP_ITEM_MAX_NUM_UNKO=100 BASE_CAMP_MAX_NUM=128 BASE_CAMP_WORKER_MAXNUM=15 DROP_ITEM_ALIVE_MAX_HOURS=1.000000 AUTO_RESET_GUILD_NO_ONLINE_PLAYERS=False AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS=72.00000 GUILD_PLAYER_MAX_NUM=20 PAL_EGG_DEFAULT_HATCHING_TIME=72.00000 WORK_SPEED_RATE=1.000000 IS_MULTIPLAY=False IS_PVP=False CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP=False ENABLE_NON_LOGIN_PENALTY=True ENABLE_FAST_TRAVEL=True IS_START_LOCATION_SELECT_BY_MAP=True EXIST_PLAYER_AFTER_LOGOUT=False ENABLE_DEFENSE_OTHER_GUILD_PLAYER=False COOP_PLAYER_MAX_NUM=4 REGION= USEAUTH=True BAN_LIST_URL=https://api.palworldgame.com/api/banlist.txt

logs

`EXECUTING USERMOD usermod: no changes STARTING INSTALL/UPDATE tid(23) burning pthread_key_t == 0 so we never use it Redirecting stderr to '/home/steam/Steam/logs/stderr.txt' Logging directory: '/home/steam/Steam/logs' [ 0%] Checking for available updates... [----] Verifying installation... [ 0%] Downloading update... [ 0%] Checking for available updates... [----] Download complete. [----] Extracting package... [----] Extracting package... [----] Extracting package... [----] Extracting package... [----] Installing update... [----] Installing update... [----] Installing update... [----] Installing update... [----] Installing update... [----] Installing update... [----] Installing update... [----] Installing update... [----] Cleaning up... [----] Update complete, launching Steamcmd... tid(35) burning pthread_key_t == 0 so we never use it Redirecting stderr to '/home/steam/Steam/logs/stderr.txt' Logging directory: '/home/steam/Steam/logs' [ 0%] Checking for available updates... [----] Verifying installation... Steam Console Client (c) Valve Corporation - version 1705108307 -- type 'quit' to exit -- Loading Steam API...OK "@sSteamCmdForcePlatformType" = "linux" "@sSteamCmdForcePlatformBitness" = "64" Connecting anonymously to Steam Public...OK Waiting for client config...OK Waiting for user info...OK Update state (0x3) reconfiguring, progress: 0.00 (0 / 0) Update state (0x3) reconfiguring, progress: 0.00 (0 / 0) Update state (0x3) reconfiguring, progress: 0.00 (0 / 0) Update state (0x3) reconfiguring, progress: 0.00 (0 / 0) Update state (0x5) verifying install, progress: 4.49 (101504697 / 2260207317) Update state (0x5) verifying install, progress: 21.21 (479328964 / 2260207317) Update state (0x5) verifying install, progress: 38.08 (860716545 / 2260207317) Update state (0x5) verifying install, progress: 54.86 (1239984516 / 2260207317) Update state (0x5) verifying install, progress: 71.69 (1620365103 / 2260207317) Update state (0x5) verifying install, progress: 88.62 (2002897565 / 2260207317) Success! App '2394010' fully installed. CHECKING FOR EXISTING CONFIG SERVER_NAME=Koala's PalWorld server SERVER_DESCRIPTION=palworld-server-docker by Thijs van Loef SERVER_PASSWORD=koala ADMIN_PASSWORD=XXX PLAYERS=8 DIFFICULTY=None DAYTIME_SPEEDRATE=1.000000 NIGHTTIME_SPEEDRATE=1.000000 EXP_RATE=1.000000 PAL_CAPTURE_RATE=1.000000 PAL_SPAWN_NUM_RATE=1.000000 PAL_DAMAGE_RATE_ATTACK=1.000000 PAL_DAMAGE_RATE_DEFENSE=1.000000 PLAYER_DAMAGE_RATE_ATTACK=1.000000 PLAYER_DAMAGE_RATE_DEFENSE=1.000000 PLAYER_STOMACH_DECREASE_RATE=1.000000 PLAYER_STAMINA_DECREASE_RATE=1.000000 PLAYER_AUTO_HP_REGEN_RATE=1.000000 PLAYER_AUTO_HP_REGEN_RATE_IN_SLEEP=1.000000 PAL_STOMACH_DECREASE_RATE=1.000000 PAL_STAMINA_DECREASE_RATE=1.000000 PAL_AUTO_HP_REGEN_RATE=1.000000 PAL_AUTO_HP_REGEN_RATE_IN_SLEEP=1.000000 BUILD_OBJECT_DAMAGE_RATE=1.000000 BUILD_OBJECT_DETERIORATION_DAMAGE_RATE=1.000000 COLLECTION_DROP_RATE=1.000000 COLLECTION_OBJECT_HP_RATE=1.000000 COLLECTION_OBJECT_RESPAWN_SPEED_RATE=1.000000 ENEMY_DROP_ITEM_RATE=1.000000 DEATH_PENALTY=All ENABLE_PLAYER_TO_PLAYER_DAMAGE=False ENABLE_FRIENDLY_FIRE=False ENABLE_INVADER_ENEMY=True ACTIVE_UNKO=False ENABLE_AIM_ASSIST_PAD=True ENABLE_AIM_ASSIST_KEYBOARD=False DROP_ITEM_MAX_NUM=3000 DROP_ITEM_MAX_NUM_UNKO=100 BASE_CAMP_MAX_NUM=128 BASE_CAMP_WORKER_MAXNUM=15 DROP_ITEM_ALIVE_MAX_HOURS=1.000000 AUTO_RESET_GUILD_NO_ONLINE_PLAYERS=False AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS=72.00000 GUILD_PLAYER_MAX_NUM=20 PAL_EGG_DEFAULT_HATCHING_TIME=72.00000 WORK_SPEED_RATE=1.000000 IS_MULTIPLAY=False IS_PVP=False CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP=False ENABLE_NON_LOGIN_PENALTY=True ENABLE_FAST_TRAVEL=True IS_START_LOCATION_SELECT_BY_MAP=True EXIST_PLAYER_AFTER_LOGOUT=False ENABLE_DEFENSE_OTHER_GUILD_PLAYER=False COOP_PLAYER_MAX_NUM=4 USEAUTH=True BAN_LIST_URL=https://api.palworldgame.com/api/banlist.txt RCON_ENABLED=true RCON_PORT=25575 BACKUP_ENABLED=true AUTO_REBOOT_ENABLED=true STARTING SERVER ./PalServer.sh -port=8211 -queryport=27015 -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS time="2024-02-05T14:07:24+08:00" level=info msg="read crontab: /home/steam/server/crontab" time="2024-02-05T14:07:24+08:00" level=fatal msg="bad crontab line: '23 30 * bash /home/steam/server/auto_reboot.sh' (use -debug for details)" [S_API] SteamAPI_Init(): Loaded local 'steamclient.so' OK. Shutdown handler: initalize. Increasing per-process limit of core file size to infinity.

thijsvanloef commented 9 months ago

Your crontab is malformed: bad crontab line: '23 30 * * * bash /home/steam/server/auto_reboot.sh Your auto reboot cron expression needs to be AUTO_REBOOT_CRON_EXPRESSION=30 23 * * * 😄

koalang commented 9 months ago

Your crontab is malformed: bad crontab line: '23 30 * * * bash /home/steam/server/auto_reboot.sh Your auto reboot cron expression needs to be AUTO_REBOOT_CRON_EXPRESSION=30 23 * * * 😄

I apologize for the cheap shot. Does this affect the cron jobs for backups?

I see that the documentation says that BACKUP_ENABLED and AUTO_UPDATE_ENABLED are both used for backups, is there a difference between the two, or is the documentation wrong?


Set BACKUP_ENABLED enable or disable automatic backups (Default is enabled)

`Set AUTO_UPDATE_ENABLED enable or disable automatic backups (Default is disabled)

thijsvanloef commented 9 months ago

I believe the documentation is wrong, the original (non translated) readme is correct BACKUP_ENABLED Enables automatic backups AUTO_UPDATE_ENABLED Enables automatic updates

koalang commented 9 months ago

I believe the documentation is wrong, the original (non translated) readme is correct BACKUP_ENABLED Enables automatic backups AUTO_UPDATE_ENABLED Enables automatic updates

I just copy from the readme 1000037825.jpg

Besides, I have a question if I need to run the Save command before backing up?

thijsvanloef commented 9 months ago

If you have RCON enabled, you do not need to save, that happens automatically: https://github.com/thijsvanloef/palworld-server-docker/blob/1ea8172e0f2ad4ae146cb69ec08174666f0d0e36/scripts/backup.sh#L4

koalang commented 9 months ago

If you have RCON enabled, you do not need to save, that happens automatically:

https://github.com/thijsvanloef/palworld-server-docker/blob/1ea8172e0f2ad4ae146cb69ec08174666f0d0e36/scripts/backup.sh#L4 Thanks for your patience and hard work!👍🏻