From 7896112b18be1ba632d33ff6a106692476daccd3 Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Tue, 11 Aug 2026 01:03:12 -0600 Subject: [PATCH] Add BACKUP_INTERVAL_MS environment variable for the Docker daemon docker-entrypoint.sh now maps BACKUP_INTERVAL_MS to -Dbackup.scheduled.interval.ms, so the scheduled backup interval can be configured from .env/docker-compose.yml without overriding the entrypoint. Closes #9 Co-Authored-By: Claude Opus 5 (1M context) --- .env.example | 5 +++++ CHANGELOG.md | 6 ++++++ CONFIG.md | 6 +++--- Dockerfile | 1 + docker-compose.yml | 7 ++++++- docker-entrypoint.sh | 5 +++++ 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 2e0e84c..e9da726 100644 --- a/.env.example +++ b/.env.example @@ -5,3 +5,8 @@ GITHUB_TOKEN=your_github_token_here # Comma-separated list of GitHub users/organizations to backup # Example: SCHEDULED_USERS=octocat,github,spring-projects SCHEDULED_USERS=octocat + +# Delay between scheduled backups, in milliseconds +# Leave empty to use the default of 86400000 (24 hours) +# Example: BACKUP_INTERVAL_MS=3600000 (1 hour) +BACKUP_INTERVAL_MS= diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c61d7a..00f78c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [Unreleased] + +### Added + +- `BACKUP_INTERVAL_MS` environment variable for the Docker daemon image, mapped by `docker-entrypoint.sh` to `-Dbackup.scheduled.interval.ms`, so the backup interval can be configured from `.env`/`docker-compose.yml` without overriding the entrypoint + ## [2.0.0-SNAPSHOT-8-8-2026] – 2026-08-08 ### Changed diff --git a/CONFIG.md b/CONFIG.md index fffb4b8..f891149 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -145,15 +145,15 @@ When the image built from the included `Dockerfile` is used, the container alway | Variable | Maps to | Default in the image | Description | |----------|---------|----------------------|-------------| | `SCHEDULED_USERS` | `backup.scheduled.users` | *(empty)* | Comma-separated list of GitHub users/organizations to back up automatically. Passed to the application only when non-empty. | +| `BACKUP_INTERVAL_MS` | `backup.scheduled.interval.ms` | *(empty)* | Delay between scheduled backups, in milliseconds. Passed to the application only when non-empty; when empty, the default of `86400000` (24 hours) from `application-daemon.properties` applies. | | `BACKUP_DIRECTORY` | `backup.directory` | `/backups` | Backup directory inside the container. | | `GITHUB_TOKEN` | *(read directly by the application)* | *(empty)* | GitHub personal access token, as described above. | -Of these, only `GITHUB_TOKEN` and `SCHEDULED_USERS` are wired through to a `.env` file by the included `docker-compose.yml` (see `.env.example`); that file pins `BACKUP_DIRECTORY` to `/backups` and mounts the host's `./backups` directory there so backups persist outside the container. - -`backup.scheduled.interval.ms` has no corresponding environment variable, so a container built from this image backs up every 24 hours unless the entrypoint is overridden. +Of these, `GITHUB_TOKEN`, `SCHEDULED_USERS` and `BACKUP_INTERVAL_MS` are wired through to a `.env` file by the included `docker-compose.yml` (see `.env.example`); that file pins `BACKUP_DIRECTORY` to `/backups` and mounts the host's `./backups` directory there so backups persist outside the container. **Example `.env`:** ``` GITHUB_TOKEN=ghp_yourTokenHere SCHEDULED_USERS=octocat,github +BACKUP_INTERVAL_MS=3600000 ``` diff --git a/Dockerfile b/Dockerfile index b473d8c..08dd246 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,7 @@ RUN mkdir -p /backups ENV BACKUP_DIRECTORY=/backups ENV GITHUB_TOKEN="" ENV SCHEDULED_USERS="" +ENV BACKUP_INTERVAL_MS="" # Expose port 8080 for optional web mode. # The default image entrypoint runs in daemon mode, so this port is only used if the diff --git a/docker-compose.yml b/docker-compose.yml index 3c178bd..aad9e48 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,12 @@ services: # Comma-separated list of GitHub users/organizations to backup # Example: SCHEDULED_USERS=octocat,github,spring-projects - SCHEDULED_USERS=${SCHEDULED_USERS:-} - + + # Delay between scheduled backups, in milliseconds + # Leave empty for the default of 86400000 (24 hours) + # Example: BACKUP_INTERVAL_MS=3600000 + - BACKUP_INTERVAL_MS=${BACKUP_INTERVAL_MS:-} + # Optional: Custom backup directory inside container - BACKUP_DIRECTORY=/backups volumes: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 0d1086f..95acb92 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -13,6 +13,11 @@ if [ -n "$SCHEDULED_USERS" ]; then set -- "$@" "-Dbackup.scheduled.users=${SCHEDULED_USERS}" fi +# Set backup interval if provided (defaults to 86400000 = 24 hours in application-daemon.properties) +if [ -n "$BACKUP_INTERVAL_MS" ]; then + set -- "$@" "-Dbackup.scheduled.interval.ms=${BACKUP_INTERVAL_MS}" +fi + # Execute the application set -- "$@" -jar gh-backup.jar exec "$@"