kopia lustrzana https://github.com/borgmatic-collective/docker-borgmatic
Porównaj commity
6 Commity
f13ef41f49
...
72f018a756
Autor | SHA1 | Data |
---|---|---|
Grant Bevis | 72f018a756 | |
modem7 | 0a1db36938 | |
modem7 | e1b5f354c7 | |
modem7 | dc39dfb078 | |
modem7 | ae2dbde91c | |
modem7 | 36f45dd340 |
|
@ -74,7 +74,7 @@ RUN --mount=type=cache,id=pip,target=/root/.cache,sharing=locked \
|
|||
borgmatic --bash-completion > "$(pkg-config --variable=completionsdir bash-completion)"/borgmatic
|
||||
EOF
|
||||
|
||||
COPY --link root/ /
|
||||
COPY --chmod=744 --link root/ /
|
||||
|
||||
VOLUME /root/.borgmatic
|
||||
VOLUME /root/.config/borg
|
||||
|
|
103
entry.sh
103
entry.sh
|
@ -1,103 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Path
|
||||
CRONTAB_PATH="/etc/borgmatic.d/crontab.txt"
|
||||
|
||||
#Variables
|
||||
borgver=$(borg --version)
|
||||
borgmaticver=$(borgmatic --version)
|
||||
apprisever=$(apprise --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
|
||||
#Software versions
|
||||
echo borgmatic $borgmaticver
|
||||
echo $borgver
|
||||
echo apprise $apprisever
|
||||
|
||||
# Enable initial debug logging based on the DEBUG_SECRETS environment variable.
|
||||
# Logs the initial values of BORG_PASSPHRASE and BORG_PASSPHRASE_FILE.
|
||||
if [ "${DEBUG_SECRETS}" = "true" ] || [ "${DEBUG_SECRETS}" = "1" ]; then
|
||||
echo "Before: BORG_PASSPHRASE: ${BORG_PASSPHRASE}"
|
||||
echo "Before: BORG_PASSPHRASE_FILE: ${BORG_PASSPHRASE_FILE}"
|
||||
fi
|
||||
|
||||
# Loop through all environment variables that start with 'BORG'.
|
||||
for var_name in $(set | grep '^BORG' | awk -F= '{print $1}'); do
|
||||
# Retrieve the current value of each environment variable.
|
||||
var_value=$(eval echo \$$var_name)
|
||||
|
||||
# Check if the variable's name ends with '_FILE'.
|
||||
if [[ "$var_name" =~ _FILE$ ]]; then
|
||||
# Strip the '_FILE' suffix to obtain the corresponding variable name.
|
||||
original_var_name=${var_name%_FILE}
|
||||
|
||||
# Retrieve the value of the original environment variable, if it exists.
|
||||
original_var_value=$(eval echo \$$original_var_name)
|
||||
|
||||
# Ensure the *_FILE variable is valid, and the referenced file exists and is not empty.
|
||||
if [ -n "$var_value" ] && [ -s "$var_value" ]; then
|
||||
# Notify user if original variable is being overwritten.
|
||||
if [ -n "$original_var_value" ]; then
|
||||
echo "Note: $original_var_name was already set but is being overwritten by $var_name"
|
||||
fi
|
||||
|
||||
# Update the original variable with the content of the file.
|
||||
export "$original_var_name"=$(cat "$var_value")
|
||||
echo "Setting $original_var_name from the content of $var_value"
|
||||
|
||||
# Unset the *_FILE environment variable.
|
||||
unset "$var_name"
|
||||
echo "Unsetting $var_name"
|
||||
else
|
||||
# Issue an error if the *_FILE variable is not properly set, or the file does not exist or is empty.
|
||||
echo "Error: File $var_value does not exist or is empty."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Enable final debug logging based on the DEBUG_SECRETS environment variable.
|
||||
# Logs the final values of BORG_PASSPHRASE and BORG_PASSPHRASE_FILE.
|
||||
if [ "${DEBUG_SECRETS}" = "true" ] || [ "${DEBUG_SECRETS}" = "1" ]; then
|
||||
echo "After: BORG_PASSPHRASE: ${BORG_PASSPHRASE}"
|
||||
echo "After: BORG_PASSPHRASE_FILE: ${BORG_PASSPHRASE_FILE}"
|
||||
fi
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
|
||||
# Allow setting of custom crontab, so check if crontab file exists
|
||||
if [ -f "$CRONTAB_PATH" ]; then
|
||||
echo "Crontab file exists, using it"
|
||||
else
|
||||
if [ -z "${BACKUP_CRON}" ]; then
|
||||
echo "Environment variable BACKUP_CRON is not set, using default value: 0 1 * * *"
|
||||
export BACKUP_CRON="0 1 * * *"
|
||||
else
|
||||
echo "Environment variable BACKUP_CRON is set, using value $BACKUP_CRON"
|
||||
fi
|
||||
echo "$BACKUP_CRON PATH=\$PATH:/usr/local/bin /usr/local/bin/borgmatic --stats -v 0 2>&1" > $CRONTAB_PATH
|
||||
fi
|
||||
|
||||
if [ "${RUN_ON_STARTUP:-}" == "true" ]; then
|
||||
echo "Running on startup..."
|
||||
/usr/local/bin/borgmatic --stats -v 0 2>&1
|
||||
fi
|
||||
|
||||
# Test crontab
|
||||
supercronic -test /etc/borgmatic.d/crontab.txt || exit 1
|
||||
|
||||
# Start supercronic
|
||||
if [ -n "${SUPERCRONIC_EXTRA_FLAGS}" ]; then
|
||||
echo "The variable SUPERCRONIC_EXTRA_FLAGS is not empty, using extra flags"
|
||||
exec supercronic $SUPERCRONIC_EXTRA_FLAGS /etc/borgmatic.d/crontab.txt
|
||||
else
|
||||
echo "The variable SUPERCRONIC_EXTRA_FLAGS is empty, starting normally"
|
||||
exec supercronic /etc/borgmatic.d/crontab.txt
|
||||
fi
|
||||
else
|
||||
if [ "$1" = "bash" ] || [ "$1" = "sh" ] || [ "$1" = "/bin/bash" ] || [ "$1" = "/bin/sh" ]; then
|
||||
# Run Shell
|
||||
exec "$@"
|
||||
else
|
||||
# Run borgmatic with subcommand
|
||||
exec borgmatic "$@"
|
||||
fi
|
||||
fi
|
|
@ -0,0 +1 @@
|
|||
oneshot
|
|
@ -0,0 +1 @@
|
|||
# This file doesn't do anything, it's just the end of the downstream image init process
|
|
@ -0,0 +1,17 @@
|
|||
#!/command/with-contenv bash
|
||||
|
||||
# Install DockerCLI if true
|
||||
if [ "${DOCKERCLI}" == "true" ]; then
|
||||
echo "[custom-init] Installing Docker CLI and Docker Compose..."
|
||||
apk add -U --quiet docker-cli docker-cli-compose
|
||||
else
|
||||
echo "[custom-init] Docker CLI variable not set, skipping..."
|
||||
fi
|
||||
|
||||
# Install additional packages
|
||||
if [ -v EXTRA_PKGS ]; then
|
||||
echo "[custom-init] Installing extra packages: $EXTRA_PKGS"
|
||||
apk add -U --quiet $EXTRA_PKGS
|
||||
else
|
||||
echo "[custom-init] No custom packages found, skipping..."
|
||||
fi
|
|
@ -0,0 +1 @@
|
|||
oneshot
|
|
@ -0,0 +1 @@
|
|||
/etc/s6-overlay/s6-rc.d/init-custom-packages/run
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/command/with-contenv bash
|
||||
|
||||
if test "$1" -eq 256 ; then
|
||||
e=$((128 + $2))
|
||||
|
@ -7,4 +7,4 @@ else
|
|||
fi
|
||||
|
||||
echo "Received exit code $e."
|
||||
echo "$e" > /run/s6-linux-init-container-results/exitcode
|
||||
echo "$e" > /run/s6-linux-init-container-results/exitcode
|
||||
|
|
|
@ -1,13 +1,4 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# Install DockerCLI if true
|
||||
if [ "${DOCKERCLI:-}" == "true" ]; then
|
||||
echo "Installing Docker CLI..."
|
||||
apk add -U --quiet docker-cli
|
||||
dockerver=$(docker --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
else
|
||||
dockerver="not installed"
|
||||
fi
|
||||
#!/command/with-contenv bash
|
||||
|
||||
# Version variables
|
||||
borgver=$(borg --version)
|
||||
|
@ -15,18 +6,34 @@ borgmaticver=$(borgmatic --version)
|
|||
apprisever=$(apprise --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
pythonver=$(python3 --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
|
||||
if [ "${DOCKERCLI}" == "true" ]; then
|
||||
dockerver=$(docker --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
composever=$(docker compose version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
else
|
||||
dockerver="not installed"
|
||||
composever="not installed"
|
||||
fi
|
||||
|
||||
# Software versions
|
||||
echo "-----------------------------------"
|
||||
echo "Software Versions:
|
||||
-----------------------------------
|
||||
apprise $apprisever
|
||||
$borgver
|
||||
borgmatic $borgmaticver
|
||||
dockercli $dockerver
|
||||
composecli $composever
|
||||
python $pythonver
|
||||
-----------------------------------
|
||||
Time Zone: $TZ
|
||||
-----------------------------------
|
||||
"
|
||||
-----------------------------------"
|
||||
if [ -v EXTRA_PKGS ]
|
||||
then
|
||||
echo "Additional packages installed:"
|
||||
echo "-----------------------------------"
|
||||
echo $EXTRA_PKGS | tr -s " " "\n"
|
||||
echo "-----------------------------------"
|
||||
fi
|
||||
|
||||
# Enable initial debug logging based on the DEBUG_SECRETS environment variable.
|
||||
# Logs the initial values of BORG_PASSPHRASE and BORG_PASSPHRASE_FILE.
|
||||
|
|
Ładowanie…
Reference in New Issue