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

cron job to backup save files #39

Closed GMBridge closed 9 months ago

GMBridge commented 9 months ago

considering how unstable the game is, automatic backups every hour or so (keeping the last X backups) would be helpful if someone needs to roll back to recover after a bug or crash.

mpfiv commented 9 months ago

also a cron job to periodically restart would be a nice addition if you are keeping backups x far back.

thijsvanloef commented 9 months ago

Open PR https://github.com/thijsvanloef/palworld-server-docker/pull/86 to create backups with a single command

cinderisles commented 9 months ago

I added a cronjob for the backup command added in #86 by adding cron to the dependencies installed in the Dockerfile

RUN apt-get update && apt-get install -y --no-install-recommends \
    xdg-user-dirs=0.17-2 \
    procps=2:3.3.17-5 \
    wget=1.21-1+deb11u1 \
    cron\
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

then added this to scripts/init.sh

echo "*/5 * * * * root /usr/local/bin/backup > /proc/1/fd/1 2>&1" > /etc/cron.d/backup
service cron start

this runs the backup command every 5 minutes

see my fork (ignore the other file changes ._.)

llnut commented 9 months ago

I added a cronjob for the backup command added in #86 by adding cron to the dependencies installed in the Dockerfile

RUN apt-get update && apt-get install -y --no-install-recommends \
    xdg-user-dirs=0.17-2 \
    procps=2:3.3.17-5 \
    wget=1.21-1+deb11u1 \
    cron\
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

then added this to scripts/init.sh

echo "*/5 * * * * root /usr/local/bin/backup > /proc/1/fd/1 2>&1" > /etc/cron.d/backup
service cron start

this runs the backup command every 5 minutes

see my fork (ignore the other file changes ._.)

I don't think automatic backup requires as much attention to the timing of the trigger as an automatic restart service does. If I were you, I would choose the following docker-compose configuration to implement the backup function, as it is obviously simpler:

backuper:
  image: docker:cli
  volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
  command: ["/bin/sh", "-c", "while true; do sleep 900; docker exec palworld-server backup; done"]
  restart: unless-stopped

of course, this is just my own opinion.

Dashboy1998 commented 9 months ago

Solved by #194.