Merge pull request #1 from GuillaumeBarreau/feat_backup_with_cron

feat:  Add Cron command to Dockerfile.
This commit is contained in:
Guillaume Barreau
2024-01-25 02:47:35 -05:00
committed by GitHub
7 changed files with 44 additions and 2 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -5,12 +5,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
xdg-user-dirs=0.17-2 \ xdg-user-dirs=0.17-2 \
procps=2:3.3.17-5 \ procps=2:3.3.17-5 \
wget=1.21-1+deb11u1 \ wget=1.21-1+deb11u1 \
&& apt-get install -y cron \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
RUN wget -q https://github.com/itzg/rcon-cli/releases/download/1.6.4/rcon-cli_1.6.4_linux_amd64.tar.gz -O - | tar -xz RUN wget -q https://github.com/itzg/rcon-cli/releases/download/1.6.4/rcon-cli_1.6.4_linux_amd64.tar.gz -O - | tar -xz
RUN mv rcon-cli /usr/bin/rcon-cli RUN mv rcon-cli /usr/bin/rcon-cli
RUN rm -f /var/run/crond.pid
COPY ./scripts/backup.sh /usr/local/bin/backup
RUN chmod +x /usr/local/bin/backup
RUN echo "0 3 * * * root bash /usr/local/bin/backup" > /etc/cron.d/backups-cron
RUN chmod 0644 /etc/cron.d/backups-cron
ENV PORT= \ ENV PORT= \
PUID=1000 \ PUID=1000 \
PGID=1000 \ PGID=1000 \

View File

@@ -162,6 +162,25 @@ docker exec palworld-server backup
This will create a backup at `/palworld/backups/` This will create a backup at `/palworld/backups/`
## Setting Up Automatic Backups with Cron
This section guides you through the process of configuring automatic backups using Cron. Use the provided command to set up the necessary Cron job for your Palworld server within a Docker environment.
The configured backup system automatically deletes backups older than 7 days to manage storage efficiently.
```bash
docker exec palworld-server cron /etc/cron.d/backups-cron
```
Additionally, to stop the cron process within the Docker container, you can use the following command:
```bash
docker exec palworld-server service cron stop
```
This command stops the cron service within the specified container, halting the scheduled cron job.
## Editing Server Settings ## Editing Server Settings
When the server starts, a `PalWorldSettings.ini` file will be created in the following location: `<mount_folder>/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini` When the server starts, a `PalWorldSettings.ini` file will be created in the following location: `<mount_folder>/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini`

View File

@@ -1,6 +1,7 @@
services: services:
palworld: palworld:
image: thijsvanloef/palworld-server-docker:latest image: test/palworld-server-docker:latest
build: .
restart: unless-stopped restart: unless-stopped
container_name: palworld-server container_name: palworld-server
ports: ports:

View File

@@ -1,8 +1,19 @@
#!/bin/bash #!/bin/bash
printf "\e[0;34m***** RUNNING SCRIPTS backup.sh *****\e[0m\n"
DATE=$(date +"%Y-%m-%d_%H-%M-%S") DATE=$(date +"%Y-%m-%d_%H-%M-%S")
FILE_PATH="/palworld/backups/palworld-save-${DATE}.tar.gz" DESTINATION_PATH="/palworld/backups"
FILE_PATH="${DESTINATION_PATH}/backup_palworld_${DATE}.tar.gz"
if [ ! -f ${FILE_PATH} ]; then
printf "\e[0;32m***** CREATING BACKUPS FOLDER *****\e[0m\n"
mkdir -p "${DESTINATION_PATH}"
fi
cd /palworld/Pal/ || exit cd /palworld/Pal/ || exit
tar -zcf "$FILE_PATH" "Saved/" tar -zcf "$FILE_PATH" "Saved/"
echo "backup created at $FILE_PATH" echo "backup created at $FILE_PATH"
find "${DESTINATION_PATH}" -type f -name "backup_palworld_*.tar.gz" -ctime +7 -exec rm -f {} \;

View File

@@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
printf "\e[0;34m***** RUNNING SCRIPTS init.sh *****\e[0m\n"
if [[ ! "${PUID}" -eq 0 ]] && [[ ! "${PGID}" -eq 0 ]]; then if [[ ! "${PUID}" -eq 0 ]] && [[ ! "${PGID}" -eq 0 ]]; then
printf "\e[0;32m*****EXECUTING USERMOD*****\e[0m\n" printf "\e[0;32m*****EXECUTING USERMOD*****\e[0m\n"
usermod -o -u "${PUID}" steam usermod -o -u "${PUID}" steam

View File

@@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
printf "\e[0;34m***** RUNNING SCRIPTS start.sh *****\e[0m\n"
STARTCOMMAND="./PalServer.sh" STARTCOMMAND="./PalServer.sh"
if [ -n "${PORT}" ]; then if [ -n "${PORT}" ]; then