itzg / docker-mc-backup

Provides a side-car container to backup itzg/minecraft-server world data
https://hub.docker.com/r/itzg/mc-backup
MIT License
334 stars 52 forks source link

backup crashes server #133

Closed clairekardas closed 1 year ago

clairekardas commented 1 year ago

Hi there,

first of all thank you for this amazing project. I have followed your example docker compose but ran into an issue on my Synology NAS when adding the backup function to my minecraft server. The server process crashes upon Thread RCON Client /172.18.0.2 started minecraft-server | [23:55:05] [Server Watchdog/ERROR]: A single server tick took 60.00 seconds (should be max 0.05)

I have added my logs here logs.zip

itzg commented 1 year ago

Some of that might be side effects from earlier failures. Specifically, in the backup container logs, this might be one of the initial causes:

2023-03-27T23:50:05.915908594Z,stderr,tar (child): /backups/world-20230327-235005.tgz: Cannot open: Permission denied

Double check that the volume/directory mounted at /backups is what you're expecting. If you can provide you container config, such as compose file, then I can help look too.

clairekardas commented 1 year ago

Thanks for your reply./backups is mounted to what I am expecting, the folder is however empty. I am confused as to why it gives a permission denied, to me it looks configured correctly.. But then again I am no expert on linux permissions.

Below my compose file. I have only removed the environment variables from the minecraft-server container.

version: '3.7'

services:
  mc:
    image: itzg/minecraft-server
    container_name: minecraft-server
    ports:
      - "25565:25565"
    volumes:
      - /volume1/docker/minecraft-server:/data
    stdin_open: true
    tty: true
    restart: unless-stopped

  backups:
    image: itzg/mc-backup
    container_name: minecraft-backups
    environment:
      BACKUP_INTERVAL: "2h"
      RCON_HOST: mc
      PRE_BACKUP_SCRIPT: |
        echo "Before backup!"
        echo "Also before backup from $$RCON_HOST to $$DEST_DIR"
      POST_BACKUP_SCRIPT_FILE: /post-backup.sh
    volumes:
      # mount the same volume used by server, but read-only
      - '/volume1/docker/minecraft-server:/data:ro'
      # use a host attached directory so that it in turn can be backed up
      # to external/cloud storage
      - './mc-backups:/backups'
      - './post-backup.sh:/post-backup.sh:ro'

volumes:
  mc: {}

My post-backup.sh has echo "Backup from $RCON_HOST to $DEST_DIR finished".

itzg commented 1 year ago

With the backups service stopped, see what this command reports:

docker compose run --entrypoint=bash backups -c 'ls -ldn /backups; id'
clairekardas commented 1 year ago

Output is unknown flag: --entrypoint.

FYI docker-compose --version outputs docker-compose version 1.28.5, build 24fb474e.

Docker version is 20.10.3, build 55f0773.

itzg commented 1 year ago

Perhaps try the compose subcommand that is now bundled into docker CLI, which is documented here

https://docs.docker.com/engine/reference/commandline/compose_run/

clairekardas commented 1 year ago

Thanks a lot for your help. I switched my server from TYPE: "VANILLA" to TYPE: "PAPER" to fix an unrelated issue (itzg/docker-minecraft-server#1411) and that happened to also fix this one! Backups work seamlessly now.