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
315 stars 52 forks source link

Receiving "Cannot open: Permission denied" error #197

Open DrewCranmer opened 1 month ago

DrewCranmer commented 1 month ago

I'm receiving a "Cannot open: Permission denied" error when trying to run a tar backup.

image

Here are the contents of my docker-compose file. Do I have something wrong?

services:
  mc:
    image: itzg/minecraft-server
    tty: true
    stdin_open: true
    ports:
      - "25565:25565"
    environment:
      EULA: "TRUE"
      TYPE: FABRIC
      VERSION: 1.20.1
      INIT_MEMORY: 1024M
      MAX_MEMORY: 5120M
      MOTD: A Drewbuntu Server
      DIFFICULTY: Normal
      SERVER_NAME: Tuxcraft Fabric
      PLAYER_IDLE_TIMEOUT: 0
      PLUGINS: |
        https://cdn.modrinth.com/data/L695BdOy/versions/EjNpDfo3/SetSpawn-3.1.jar
      ICON: https://icons.iconarchive.com/icons/papirus-team/papirus-apps/72/tux-icon.png
    depends_on:
      restore-backup:
        condition: service_completed_successfully
    volumes:
      - ./minecraft-data:/data
      - ./mods.txt:/extras/mods.txt:ro
  restore-backup:
    # Same image as mc, but any base image with bash and tar will work                                                      
    image: itzg/mc-backup
    user: "1000"
    restart: no
    entrypoint: restore-tar-backup
    volumes:
      # Must be same mount as mc service, needs to be writable
      - ./minecraft-data:/data
      # Must be same mount as backups service, but can be read-only
      - ./minecraft-backups:/backups:ro
  backups:
    image: itzg/mc-backup
    user: "1000"
    depends_on:
      mc:
        condition: service_healthy
    environment:
      BACKUP_INTERVAL: "4h"
      RCON_HOST: mc
      # since this service waits for mc to be healthy, no initial delay is needed
      INITIAL_DELAY: 0
      # As an example, to backup only the world data:
      # INCLUDES: world,world_nether,world_the_end
      PRUNE_BACKUPS_DAYS: 7
    volumes:
      - ./minecraft-data:/data:ro
      - ./minecraft-backups:/backups
itzg commented 1 month ago

Double check the ownership and/or permissions on your host directory ./minecraft-data. The containers are accessing that as user ID 1000. If you're running root-less containers such as with podman, I believe you'll also need to lookup the UID mapping.

DrewCranmer commented 1 month ago

I thought I had already changed permissions to grant other users read and write. When looking at ownership, however, I noticed that my minecraft-backups folder was owned by root:root. image

I changed it to drew:drew like all of the others.... image

....and now the backup works! image

Thank you so much for the speedy reply!