mbround18 / valheim-docker

Valheim Docker powered by Odin. The Valheim dedicated gameserver manager which is designed with resiliency in mind by providing automatic updates, world backup support, and a user friendly cli interface.
https://hub.docker.com/r/mbround18/valheim
BSD 3-Clause "New" or "Revised" License
757 stars 81 forks source link

Non-Existent Cron Directory Causing Auto-Backup to Not Trigger #784

Closed mbround18 closed 6 months ago

mbround18 commented 6 months ago

Discussed in https://github.com/mbround18/valheim-docker/discussions/783

Originally posted by **algo7** January 26, 2024 When the `setup_cron` fuction is called in the `entrypoint.sh` in the docker container, it does not check for the existence of the directory`$HOME/cron.d`. I am using image version: `mbround18/valheim:2.4` and it seems like the `/home/steam/cron.d` is not created as part of the Docker image build nor as part of the `entrypoint.sh`. The missing directory has caused the cron job setup to fail as can be seen from the server log attached below. For me, the auto-backup is not working for this reason. I assume that other jobs such as auto-update and scheduled restart that depend on cron will also fail to work. It seems like the problem also exists in previous version of the image, because my backup stopped long ago and i have updated my image several times throughout the past few months. I have not realized this until I updated my image to 2.4. Is it possible to issue a fix by either creating the directory during the image builds or as part of the `entrypoint.sh`? # setup_cron function in `entrypoint.sh` ```bash setup_cron() { set -f CRON_NAME=$1 SCRIPT_PATH="$HOME/scripts/$2" CRON_SCHEDULE=$3 LOG_LOCATION="$HOME/valheim/logs/$CRON_NAME.out" mkdir -p "$HOME/valheim/logs" [ -f "$LOG_LOCATION" ] && rm "$LOG_LOCATION" printf "%s %s /bin/bash %s >> %s 2>&1" \ "${CRON_SCHEDULE}" \ "BASH_ENV=/env.sh" \ "${SCRIPT_PATH}" \ "${LOG_LOCATION}" \ | tee "$HOME/cron.d/${CRON_NAME}" echo "" | tee -a "$HOME/cron.d/${CRON_NAME}" # Give execution rights on the cron job chmod 0644 "$HOME/cron.d/${CRON_NAME}" set +f } ``` # Server Logs ```bash Europe/Zurich 2024-01-27 07:11:14 - #[INFO]: ########################################################################### 2024-01-27 07:11:14 - [Valheim][INFO]: Valheim Server - Sat Jan 27 07:11:14 AM CET 2024 2024-01-27 07:11:14 - [Valheim][INFO]: Initializing your container... 2024-01-27 07:11:14 - [Valheim][INFO]: Total memory: 31GB 2024-01-27 07:11:14 - #[INFO]: ########################################################################### Configuring Preset Env export DEBUG_MODE=0 export ODIN_CONFIG_FILE="/home/steam/valheim/config.json" export ODIN_DISCORD_FILE="/home/steam/valheim/discord.json" export ODIN_WORKING_DIR="" export SAVE_LOCATION="/home/steam/.config/unity3d/IronGate/Valheim" export MODS_LOCATION="/home/steam/staging/mods" export GAME_LOCATION="/home/steam/valheim" export BACKUP_LOCATION="/home/steam/backups" export NAME="REDACTED" export ADDRESS="" export PORT=2456 export PUBLIC=1 export ENABLE_CROSSPLAY=0 export UPDATE_ON_STARTUP=1 export SERVER_EXTRA_LAUNCH_ARGS="" export WEBHOOK_URL="" export WEBHOOK_STATUS_SUCCESSFUL=1 export WEBHOOK_STATUS_FAILED=1 export WEBHOOK_STATUS_RUNNING=1 export WEBHOOK_INCLUDE_PUBLIC_IP=0 export AUTO_UPDATE=1 export AUTO_BACKUP=1 export AUTO_BACKUP_REMOVE_OLD=0 export AUTO_BACKUP_DAYS_TO_LIVE=5 export AUTO_BACKUP_ON_UPDATE=1 export AUTO_BACKUP_ON_SHUTDOWN=1 export AUTO_BACKUP_PAUSE_WITH_NO_PLAYERS=0 export VALHEIM_PLUS_RELEASES_URL="" export VALHEIM_PLUS_DOWNLOAD_URL="" export BEPINEX_RELEASES_URL="https://valheim.thunderstore.io/api/experimental/package/denikson/BepInExPack_Valheim/" export BEPINEX_DOWNLOAD_URL="" export BEPINEX_FULL_RELEASES_URL="" Preset Env Configured 2024-01-27 07:11:15 - [Valheim][INFO]: Auto Update Enabled... 2024-01-27 07:11:15 - [Valheim][INFO]: Auto Update Schedule: 0 1 * * * tee: /home/steam/cron.d/auto-update: No such file or directory tee: /home/steam/cron.d/auto-update: No such file or directory 0 1 * * * BASH_ENV=/env.sh /bin/bash /home/steam/scripts/auto_update.sh >> /home/steam/valheim/logs/auto-update.out 2>&1 chmod: cannot access '/home/steam/cron.d/auto-update': No such file or directory 2024-01-27 07:11:15 - [Valheim][INFO]: Auto Backup Enabled... 2024-01-27 07:11:15 - [Valheim][INFO]: Auto Backup Schedule: */15 * * * * tee: /home/steam/cron.d/auto-backup: No such file or directory tee: /home/steam/cron.d/auto-backup: No such file or directory */15 * * * * BASH_ENV=/env.sh /bin/bash /home/steam/scripts/auto_backup.sh >> /home/steam/valheim/logs/auto-backup.out 2>&1 chmod: cannot access '/home/steam/cron.d/auto-backup': No such file or directory cat: '/home/steam/cron.d/*': No such file or directory 2024-01-27 07:11:15 - [Valheim][INFO]: Setting up file systems ```