docker-mc-backup icon indicating copy to clipboard operation
docker-mc-backup copied to clipboard

Help: Unable to get mc-backup working, cannot connect to RCON.

Open ghcrow opened this issue 3 years ago • 2 comments

Hi, me again. Realised I wasn't running backups for my server the past 6 months when I thought I was. So, went about getting backups started and found this repo. Just having some teething issues getting it working and would appreciate any guidance you could share! This is the following issue I am seeing in the logs of my "minecraft_backups_1" container that is running.

2021-07-11T17:41:14+0000 ERROR Unable to execute rcon-cli save-on - try 0/20. Retrying in 10s,
2021-07-11T17:41:14+0000 ERROR Failure reason: 2021/07/11 17:41:14 Failed to connect to RCON serverdial tcp 127.0.0.1:25575: connect: connection refused	

The docker-compose.yml file I used is as follows:

version: '3.7'

services:
  backups:
    image: itzg/mc-backup
    environment:
      BACKUP_INTERVAL: "1d"
      BACKUP_NAME: "new-survival"  # I put this as the name of my world incase they needed to match, was unsure
      PRUNE_BACKUP_DAYS: "7"
      EXCLUDES: ".jar,cache,logs"
      BACKUP_METHOD: "tar"
      INITIAL_DELAY: 30s
      # instead of network_mode below, could declare RCON_HOST
      RCON_HOST: minecraft # tried this with localhost as well but to no avail
      RCON_PORT: 25575 # default
      RCON_PASSWORD: minecraft # default
    volumes:
    # mount the same volume used by server, but read-only
    - minecraft:/data:ro
    # use a host attached directory so that it in turn can be backed up
    # to external/cloud storage
    - ./mc-backups:/backups # I have created a directory called `mc-backups` at the same level as this file
    # share network namespace with server to simplify rcon access - there is no minecraft service yet.
    # network_mode: "service:minecraft"
    networks:
      mc-backup:
    restart: unless-stopped

volumes:
  minecraft: {}  # I think this needs mapping to my volume used for the server but was unable to do so, hence changed in portainer

# Saw this mentioned in Issue 5 for this repo and thought I may need it. 
networks:
  mc-backup:
    internal: true

Once the container has booted, I always need to change the /data for the read-only aspect as it never points at the volume I use for my server container (likely a config issue in the script but easy enough to change on portainer). I think the issue is to do with networking/services? I don't have a "minecraft" service running on my box - I didn't use docker-compose file for setting that up.

Very much on a learning curve with containers currently so any guidance appreciated. If you need any more details please let me know. Have read the documentation but wasn't able to get anywhere.

ghcrow avatar Jul 11 '21 17:07 ghcrow

There's potentially several things configured incorrectly there

  • I'm not sure how RCON_HOST: minecraft would resolve to the loopback address 127.0.0.1, so your example output seems to be from your attempt at RCON_HOST: localhost
  • The minecraft volume you're referencing is local to the compose project, so has no relation to your minecraft server's data volume
  • You declared an mc-backup network local to the compose project, which means the minecraft server itself is not on that network so inter-container networking and hostname resolution won't work

Any chance you can keep things simple and add the backup service to an existing compose file with your minecraft server like the example:

https://github.com/itzg/docker-mc-backup#docker-compose

itzg avatar Jul 11 '21 22:07 itzg

EDIT: I added my minecraft server to the new network mc-backup that the backup one created and this provided inter-container networking so I think it should be working now, thank you! Thought it would be a networking issue. In relation to your bullet points:

  • Good spot, I copied the wrong lines from the log for this attempt. This was indeed the localhost variable. Happy to copy across the minecraft one too if that helps, but may be worth trying to figure the network stuff first.
  • Yeah this is the volume that I changed within portainer once the container had been set up by the compose project, so the read only volume is my minecraft server, and the write one is the backups one.
  • I will give the networking a go - I imagine it may be the fact that my server is only on the bridge network and not an internal network, which both this and the mc-backup containers need to be on.

I did try that compose file, however I didn't use a compose file for my server when I first set it up. I just ran the docker CLI command and then configured settings within portainer. That one didn't work because there was no minecraft service that was running?

ghcrow avatar Jul 12 '21 07:07 ghcrow