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
298 stars 51 forks source link

tar method does not prune old files #186

Closed jack-mil closed 1 month ago

jack-mil commented 1 month ago

I am running with the backup now oneshot method, triggered by a cron job starting the docker container at specific times, as described in #156. However, pruning old files does not occur. I have to manually go in and remove old files every few days so I don't run out of space. My world file is very large (18 GB uncompressed), so I am getting the "file changed as we read it" as decscribed in #56. Unsure if that is related or not. Backing up takes ~6 minutes.

Can anyone confirm if this is only any issue with one-shot backups? Does the container need to be long-running to delete old files correctly?

recent log:

2024-06-12T12:16:46-0400 INFO waiting for rcon readiness...
2024-06-12T12:16:46-0400 INFO Command executed successfully rcon-cli save-on
2024-06-12T12:16:46-0400 INFO Command executed successfully rcon-cli save-off
2024-06-12T12:16:50-0400 INFO Command executed successfully rcon-cli save-all flush
2024-06-12T12:16:50-0400 INFO Command executed successfully sync
2024-06-12T12:16:50-0400 INFO Backing up content in /data to /backups/world-20240612-121650.tar.zst
tar: world: file changed as we read it
2024-06-12T12:22:31-0400 WARN Dat files changed as we read it
2024-06-12T12:22:31-0400 INFO Command executed successfully rcon-cli save-on

dockercompose:

  backups:
    image: itzg/mc-backup
    environment:
      BACKUP_INTERVAL: "-1"
      RCON_HOST: mc
      RCON_PASSWORD: "<PASSWORD>"
      INITIAL_DELAY: "1h"
      PRUNE_BACKUP_DAYS: 4
      INCLUDES: world
      LINK_LATEST: true
      BACKUP_METHOD: "tar"
      TAR_COMPRESS_METHOD: "zstd"
      TZ: "America/New_York"
    depends_on:
      mc:
        condition: service_healthy
    volumes:
      # mount the same volume used by server, but read-only
      - ./data:/data:ro
      - /mnt/backups:/backups
itzg commented 1 month ago

The "backup now" mode does include file pruning. The latest image now logs the info message about pruning every time since it was also confusing to me when I was testing. You can set the DEBUG env var to "true" to see exactly what it is doing during the prune step.

jack-mil commented 1 month ago

Ok , thank you so much! That helped me identify that I was using the wrong environment variable PRUNE_BACKUP_DAYS instead of PRUNE_BACKUPS_DAYS. I also was able to trim my world quite a bit today, so the file size is much more managable, and backups take much less time. I think I never saw the script deleting old backps (I had it set to 4 days) because I would run out of disk space due to my large world size before it got to the default of 7 days.