kopia lustrzana https://github.com/modem7/docker-borgmatic
Porównaj commity
6 Commity
e962dd0e27
...
fa9bec5e5e
Autor | SHA1 | Data |
---|---|---|
modem7 | fa9bec5e5e | |
modem7 | 37d5e7f819 | |
modem7 | face292d3f | |
modem7 | 99ca225aa3 | |
modem7 | 20643ba32f | |
modem7 | 8416343d33 |
17
README.md
17
README.md
|
@ -35,13 +35,22 @@ It uses cron to run the backups at a time you can configure in `data/borgmatic.d
|
|||
# Environment Variables
|
||||
| Variable | Description | Possible Values | Default |
|
||||
| :----: | --- | --- | --- |
|
||||
| DOCKERCLI | Install DockerCLI | true | Empty |
|
||||
| CRON | Cron times | cron time, disabled | 0 1 * * * |
|
||||
| DOCKERCLI | Install DockerCLI and ComposeCLI | true | Empty |
|
||||
| EXTRA_PKGS | Install additional packages | rclone coreutils jq other_packages | Empty |
|
||||
| CRON | Cron times | cron time, false | 0 1 * * * |
|
||||
| CRON_COMMAND | Command cron will run | borgmatic --stats -v 0 2>&1 | borgmatic --stats -v 0 2>&1 |
|
||||
| EXTRA_CRON | Extra cron lines | 0 5 2 * * command1 | Empty |
|
||||
|
||||
## Breaking change
|
||||
dockercli tag has been removed as there is now a variable to install it at container startup.
|
||||
## Customising the container
|
||||
Simply mount a volume located at /custom-cont-init.d and add any scripts you want. These scripts can contain logic for installing packages, copying over custom files to other locations, or installing plugins.
|
||||
|
||||
For example:
|
||||
```yaml
|
||||
services:
|
||||
borgmatic:
|
||||
volumes:
|
||||
- /home/foo/my-custom-files:/custom-cont-init.d:ro
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,21 +6,89 @@ 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.
|
||||
if [ "${DEBUG_SECRETS}" = "true" ] || [ "${DEBUG_SECRETS}" = "1" ]; then
|
||||
echo "Before: BORG_PASSPHRASE: ${BORG_PASSPHRASE}"
|
||||
echo "Before: BORG_PASSPHRASE_FILE: ${BORG_PASSPHRASE_FILE}"
|
||||
echo "Before: YOUR_PASSPHRASE: ${YOUR_PASSPHRASE}"
|
||||
echo "Before: YOUR_PASSPHRASE_FILE: ${YOUR_PASSPHRASE_FILE}"
|
||||
fi
|
||||
|
||||
# Loop through all environment variables that start with 'BORG'.
|
||||
for var_name in $(set | grep -E '^BORG|^YOUR' | 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 "Before: BORG_PASSPHRASE: ${BORG_PASSPHRASE}"
|
||||
echo "Before: BORG_PASSPHRASE_FILE: ${BORG_PASSPHRASE_FILE}"
|
||||
echo "Before: YOUR_PASSPHRASE: ${YOUR_PASSPHRASE}"
|
||||
echo "Before: YOUR_PASSPHRASE_FILE: ${YOUR_PASSPHRASE_FILE}"
|
||||
fi
|
||||
|
||||
# Disable cron if it's set to disabled.
|
||||
if [[ "$CRON" =~ ^(false|disabled|off)$ ]]; then
|
||||
if [[ "$CRON" = "false" ]]; then
|
||||
echo "Disabling cron, removing configuration"
|
||||
# crontab -r # quite destructive
|
||||
# echo -n > /etc/crontabs/root # Empty config, doesn't look as nice with "crontab -l"
|
||||
|
|
Ładowanie…
Reference in New Issue