Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BACKUP_ON_STARTUP option #198

Merged
merged 2 commits into from
Aug 4, 2024
Merged

Add BACKUP_ON_STARTUP option #198

merged 2 commits into from
Aug 4, 2024

Conversation

wyne
Copy link
Contributor

@wyne wyne commented Aug 2, 2024

Add BACKUP_ON_STARTUP option to configure whether a backup is initiated immediately upon start.

It can be useful to set this to false especially when working on your first configuration. As you iterate on your configuration and restart the backup server often, this will prevent duplicate backups for each restart.

Setting to false will wait for the BACKUP_INTERVAL before the first backup. Additionally, it will wait until a player has been active before initiating a backup according to PAUSE_IF_NO_PLAYERS.

Copy link
Owner

@itzg itzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you describe your testing approach? From what I'm seeing may not work the way you're wanting in an all cases.

Comment on lines 624 to 626
elif [[ $first_run == TRUE && ${BACKUP_ON_STARTUP^^} = FALSE ]]; then
log INFO "Skipping backup on startup"
first_run=false
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the right place for the conditional. This is for the case when the server is auto-paused.

Won't the backup call on line 605 happen still?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice, this works for me as I expected. I'll take another look if I can figure out a better option.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide your compose file or equivalent used for testing.

@wyne
Copy link
Contributor Author

wyne commented Aug 3, 2024

I was running into issues with running the current tests on Apple Silicon, so I'll need to revisit those and update the PR.

@wyne
Copy link
Contributor Author

wyne commented Aug 3, 2024

You're right, the original didn't work for all cases. I think it was working for me because my servers were already up and paused.

I moved the conditional up, which seems more correct. But I'll still do more testing.

Here's the test compose file I used:

# docker-compose.yml
services:
  mc:
    image: itzg/minecraft-server
    restart: always
    tty: true
    stdin_open: true
    ports:
      - "25565:25565"
    environment:
      EULA: "TRUE"
      ENABLE_AUTOPAUSE: "TRUE"
      AUTOPAUSE_TIMEOUT_EST: 30
    volumes:
      - "./data:/data"

  backup:
    restart: "no"
    build: .
    depends_on:
      mc:
        condition: service_healthy
    environment:
      BACKUP_INTERVAL: "1h"
      # BACKUP_ON_STARTUP: false
      RCON_HOST: mc
      INITIAL_DELAY: 0
      PAUSE_IF_NO_PLAYERS: true
    deploy:
      resources:
        limits:
          memory: 2G
    volumes:
      - "./data:/data:ro"
      - "./backups:/backups"

Copy link
Owner

@itzg itzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's better 😀

@itzg itzg merged commit e6fb4c1 into itzg:master Aug 4, 2024
1 check passed
@itzg itzg added the enhancement New feature or request label Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants