Porównaj commity

...

49 Commity

Autor SHA1 Wiadomość Data
Grant Bevis be6bf729fd
Merge pull request #319 from trash-it/patch-2
Update README.md
2024-04-30 08:09:10 +01:00
Grant Bevis ac7568a53a
Merge pull request #326 from borgmatic-collective/dependabot/pip/borgmatic-apprise--1.8.11
Bump borgmatic[apprise] from 1.8.10 to 1.8.11
2024-04-30 08:08:39 +01:00
dependabot[bot] cc538bf7d1
Bump borgmatic[apprise] from 1.8.10 to 1.8.11
Bumps [borgmatic[apprise]](https://github.com/borgmatic-collective/borgmatic) from 1.8.10 to 1.8.11.
- [Release notes](https://github.com/borgmatic-collective/borgmatic/releases)
- [Changelog](https://github.com/borgmatic-collective/borgmatic/blob/main/NEWS)
- [Commits](https://github.com/borgmatic-collective/borgmatic/compare/1.8.10...1.8.11)

---
updated-dependencies:
- dependency-name: borgmatic[apprise]
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-29 22:53:58 +00:00
Grant Bevis 72f018a756
Merge pull request #324 from modem7/extra-pkgs
Extra pkgs
2024-04-25 11:08:22 +01:00
modem7 0a1db36938
Delete entry.sh
No longer used
2024-04-25 08:05:38 +01:00
modem7 e1b5f354c7
Cleaning up scripts 2024-04-25 07:44:40 +01:00
modem7 dc39dfb078
Fix S6 bugs and simplify future work 2024-04-25 07:42:31 +01:00
modem7 ae2dbde91c
Fix software versions 2024-04-24 20:43:51 +01:00
modem7 36f45dd340
Extra pkgs 2024-04-24 20:04:18 +01:00
Grant Bevis f13ef41f49
Merge pull request #322 from modem7/echo-printf
change printf to echo
2024-04-22 09:17:34 +01:00
modem7 d3ba94d1ba
change printf to echo
This resolves issues with printf syntax which doesn't play well with % symbols
2024-04-21 21:28:34 +01:00
trash-it b15a77092b
Update README.md
Add apprise state definition
2024-04-20 09:38:10 +02:00
Grant Bevis 747090a42b
Merge pull request #316 from borgmatic-collective/1.8.10-xxhash
Add xxhash package to build and update to 1.8.10
2024-04-18 09:34:32 +01:00
Grant Bevis acd7a310f9 Add xxhash package to build 2024-04-18 09:32:39 +01:00
Grant Bevis f2047cbf14
Merge pull request #315 from borgmatic-collective/dependabot/pip/borgmatic-apprise--1.8.10
Bump borgmatic[apprise] from 1.8.9 to 1.8.10
2024-04-18 09:25:45 +01:00
dependabot[bot] 8f42391f74
Bump borgmatic[apprise] from 1.8.9 to 1.8.10
Bumps [borgmatic[apprise]](https://github.com/borgmatic-collective/borgmatic) from 1.8.9 to 1.8.10.
- [Release notes](https://github.com/borgmatic-collective/borgmatic/releases)
- [Changelog](https://github.com/borgmatic-collective/borgmatic/blob/main/NEWS)
- [Commits](https://github.com/borgmatic-collective/borgmatic/compare/1.8.9...1.8.10)

---
updated-dependencies:
- dependency-name: borgmatic[apprise]
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-16 22:26:30 +00:00
Grant Bevis bab1f5ae25
Merge pull request #312 from borgmatic-collective/dependabot/docker/python-3.12.3-alpine3.19
Bump python from 3.12.2-alpine3.19 to 3.12.3-alpine3.19
2024-04-11 11:33:42 +01:00
dependabot[bot] ffcc12b39d
Bump python from 3.12.2-alpine3.19 to 3.12.3-alpine3.19
Bumps python from 3.12.2-alpine3.19 to 3.12.3-alpine3.19.

---
updated-dependencies:
- dependency-name: python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-10 22:59:07 +00:00
Grant Bevis 451b98d64a
Merge pull request #303 from modem7/s6
Move to S6
2024-04-01 20:11:08 +01:00
modem7 7837fe85ac
Merge branch 'master' into s6 2024-04-01 18:55:58 +01:00
Grant Bevis 1959c61a84
Merge pull request #311 from borgmatic-collective/grantbevis/borgbackup-1.2.8
borgbackup 1.2.8
2024-03-30 14:20:48 +00:00
Grant Bevis c9249c32d1
borgbackup 1.2.8 2024-03-30 14:20:35 +00:00
Grant Bevis d917f697c5
Merge pull request #309 from witten/master
Mention borgmatic 1.8.9+ Apprise log sending capability.
2024-03-30 14:19:30 +00:00
modem7 43a5d3d3ae
Update config and run
Fix typo and resolve inconsistency
2024-03-24 04:36:57 +00:00
modem7 e9f71e51b5
Merge branch 'master' into s6 2024-03-16 15:42:01 +00:00
modem7 13b0e605ce
Merge pull request #1 from Psycho0verload/s6
Add Secrets for BORG & YOUR
2024-03-16 15:41:24 +00:00
Jonathan Starck 80d11da9bb
Add Secrets for BORG & YOUR
Add Secrets for BORG & YOUR
2024-03-16 16:24:36 +01:00
modem7 413af599cf
Updating package versions 2024-03-13 01:22:45 +00:00
Dan Helfman c9e922ce94 Mention borgmatic 1.8.9+ Apprise log sending capability. 2024-03-11 15:36:32 -07:00
Grant Bevis c2bf0d6b4f
Merge pull request #307 from borgmatic-collective/1.8.9
1.8.9
2024-03-11 20:52:59 +00:00
Grant Bevis b8b525c5ef
1.8.9
1.8.9
2024-03-11 20:52:33 +00:00
Grant Bevis d337d6dec0
Merge pull request #305 from borgmatic-collective/dependabot/pip/apprise-1.7.3
Bump apprise from 1.7.2 to 1.7.3
2024-03-05 07:00:25 +00:00
dependabot[bot] 60e1c0f68e
Bump apprise from 1.7.2 to 1.7.3
Bumps [apprise](https://github.com/caronc/apprise) from 1.7.2 to 1.7.3.
- [Release notes](https://github.com/caronc/apprise/releases)
- [Commits](https://github.com/caronc/apprise/compare/v1.7.2...v1.7.3)

---
updated-dependencies:
- dependency-name: apprise
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-04 22:52:35 +00:00
modem7 d3155314b3
Update healthcheck 2024-02-28 00:03:59 +00:00
modem7 3b8ade53cc
Update config example 2024-02-27 02:43:09 +00:00
modem7 49fb9b590e
Fix whitespace 2024-02-27 00:50:45 +00:00
modem7 d0953b4468
update config example 2024-02-27 00:45:25 +00:00
modem7 ea6d942f35
change ownership
change ownership from modem7 to  borgmatic-collective
2024-02-26 21:26:30 +00:00
modem7 670f70eabb
Move to S6 2024-02-24 20:16:51 +00:00
Grant Bevis 8e822f49cc
Merge pull request #299 from borgmatic-collective/dependabot/pip/borgmatic-1.8.8
Bump borgmatic from 1.8.7 to 1.8.8
2024-02-01 08:17:42 +00:00
dependabot[bot] 5395d70403
Bump borgmatic from 1.8.7 to 1.8.8
Bumps [borgmatic](https://github.com/borgmatic-collective/borgmatic) from 1.8.7 to 1.8.8.
- [Release notes](https://github.com/borgmatic-collective/borgmatic/releases)
- [Changelog](https://github.com/borgmatic-collective/borgmatic/blob/main/NEWS)
- [Commits](https://github.com/borgmatic-collective/borgmatic/compare/1.8.7...1.8.8)

---
updated-dependencies:
- dependency-name: borgmatic
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-31 22:29:53 +00:00
Grant Bevis 42e312f0fb
Merge pull request #296 from borgmatic-collective/dependabot/pip/apprise-1.7.2
Bump apprise from 1.6.0 to 1.7.2
2024-01-30 07:29:26 +00:00
dependabot[bot] 2432a60b6b
Bump apprise from 1.6.0 to 1.7.2
Bumps [apprise](https://github.com/caronc/apprise) from 1.6.0 to 1.7.2.
- [Release notes](https://github.com/caronc/apprise/releases)
- [Commits](https://github.com/caronc/apprise/compare/v1.6.0...v1.7.2)

---
updated-dependencies:
- dependency-name: apprise
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-29 22:20:58 +00:00
Grant Bevis c8a21f73c0
Merge pull request #292 from borgmatic-collective/grantbevis/1.8.7
Update requirements.txt
2024-01-22 07:16:49 +00:00
Grant Bevis 6b8ab88b89
Update requirements.txt 2024-01-22 07:16:30 +00:00
Grant Bevis 2a56a5b9ba
Merge pull request #282 from borgmatic-collective/dependabot/pip/borgbackup-1.2.7 2023-12-05 06:40:49 +00:00
dependabot[bot] 701448520b
Bump borgbackup from 1.2.6 to 1.2.7
Bumps [borgbackup](https://github.com/borgbackup/borg) from 1.2.6 to 1.2.7.
- [Release notes](https://github.com/borgbackup/borg/releases)
- [Changelog](https://github.com/borgbackup/borg/blob/master/docs/changes_1.x.rst)
- [Commits](https://github.com/borgbackup/borg/compare/1.2.6...1.2.7)

---
updated-dependencies:
- dependency-name: borgbackup
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-04 22:50:19 +00:00
Grant Bevis 7fa0eafd64
Merge pull request #281 from borgmatic-collective/dependabot/pip/borgmatic-1.8.5 2023-11-21 05:33:43 +00:00
dependabot[bot] 60472507bd
Bump borgmatic from 1.8.4 to 1.8.5
Bumps [borgmatic](https://github.com/borgmatic-collective/borgmatic) from 1.8.4 to 1.8.5.
- [Release notes](https://github.com/borgmatic-collective/borgmatic/releases)
- [Changelog](https://github.com/borgmatic-collective/borgmatic/blob/main/NEWS)
- [Commits](https://github.com/borgmatic-collective/borgmatic/compare/1.8.4...1.8.5)

---
updated-dependencies:
- dependency-name: borgmatic
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-20 22:33:19 +00:00
18 zmienionych plików z 263 dodań i 162 usunięć

Wyświetl plik

@ -1,41 +1,85 @@
# syntax = docker/dockerfile:latest
FROM python:3.11.5-alpine3.18
LABEL maintainer='github.com/borgmatic-collective'
VOLUME /mnt/source
VOLUME /mnt/borg-repository
FROM python:3.12.3-alpine3.19 as base
ARG TARGETARCH
LABEL maintainer='borgmatic-collective'
FROM base AS base-amd64
ENV S6_OVERLAY_ARCH=x86_64
FROM base AS base-arm64
ENV S6_OVERLAY_ARCH=aarch64
FROM base-${TARGETARCH}${TARGETVARIANT}
ARG S6_OVERLAY_VERSION=3.1.6.2
# Add S6 Overlay
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp/s6-overlay.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
# Add S6 optional symlinks
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp
ENV LANG='en_US.UTF-8' \
LANGUAGE='en_US.UTF-8' \
TERM='xterm' \
S6_LOGGING="1" \
S6_VERBOSITY="0" \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME="0" \
TZ="Europe/London"
RUN <<EOF
set -xe
apk upgrade --update --no-cache
tar -C / -Jxpf /tmp/s6-overlay.tar.xz
tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
tar -C / -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz
tar -C / -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz
apk add --no-cache -U \
bash \
bash-completion \
bash-doc \
ca-certificates \
curl \
findmnt \
fuse \
libacl \
libxxhash \
logrotate \
lz4-libs \
mariadb-client \
mariadb-connector-c \
mongodb-tools \
openssl \
pkgconfig \
postgresql-client \
sqlite \
sshfs \
tzdata \
xxhash
apk upgrade --no-cache
EOF
COPY --link requirements.txt /
RUN --mount=type=cache,id=pip,target=/root/.cache,sharing=locked \
<<EOF
set -xe
python3 -m pip install -U pip
python3 -m pip install -Ur requirements.txt
borgmatic --bash-completion > "$(pkg-config --variable=completionsdir bash-completion)"/borgmatic
EOF
COPY --chmod=744 --link root/ /
VOLUME /root/.borgmatic
VOLUME /etc/borgmatic.d
VOLUME /root/.config/borg
VOLUME /root/.ssh
VOLUME /root/.cache/borg
RUN apk add --update --no-cache \
bash \
bash-completion \
bash-doc \
ca-certificates \
curl \
findmnt \
fuse \
libacl \
logrotate \
lz4-libs \
mariadb-client \
mariadb-connector-c \
mongodb-tools \
openssl1.1-compat \
postgresql-client \
sqlite \
sshfs \
supercronic \
tzdata \
&& rm -rf \
/var/cache/apk/* \
/.cache
COPY --chmod=755 entry.sh /entry.sh
COPY requirements.txt /
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 CMD borgmatic config validate
RUN python3 -m pip install --no-cache -Ur requirements.txt
RUN borgmatic --bash-completion > /usr/share/bash-completion/completions/borgmatic && echo "source /etc/bash/bash_completion.sh" > /root/.bashrc
ENTRYPOINT ["/entry.sh"]
ENTRYPOINT [ "/init" ]

Wyświetl plik

@ -154,6 +154,11 @@ Starting from version 1.8.4, Borgmatic has native support for Apprise within its
```yaml
apprise:
states:
- start
- finish
- fail
services:
- url: mailto://smtp.example.com:587?user=info@example.com&pass=YourSecurePassword&from=server@example.com
label: mail
@ -173,15 +178,7 @@ apprise:
body: Your backups have failed.
```
#### Important Note
Just like in the previous configuration, you can use `$(cat /tmp/backup_run.log)` to send log outputs as part of the notification body. Simply replace the `body` value with this variable to include the log in your notifications.
```yaml
finish:
title: ✅ SUCCESS
body: $(cat /tmp/backup_run.log)
```
And as of borgmatic 1.8.9+, borgmatic's logs are automatically appended to the `body` for each notification.
### Conclusion

Wyświetl plik

@ -4,31 +4,41 @@ repositories:
- path: /mnt/borg-repository
one_file_system: true
# Passphrase is set in variable $BORG_PASSPHRASE
# encryption_passphrase: "DoNotMissToChangeYourPassphrase"
# Passphase is set in varibable $BORG_PASSPHRASE
# encryption_passphrase: "DoNotForgetToChangeYourPassphrase"
compression: lz4
archive_name_format: 'backup-{now}'
keep_hourly: 2
keep_daily: 7
keep_weekly: 4
keep_monthly: 12
keep_yearly: 10
checks:
- name: repository
- name: archives
check_last: 3
- name: repository
frequency: 2 weeks
- name: archives
frequency: always
- name: extract
frequency: 2 weeks
- name: data
frequency: 1 month
hooks:
before_backup:
- echo "Starting a backup job."
after_backup:
- echo "Backup created."
on_error:
- echo "Error while creating a backup."
before_backup:
before_everything:
- echo "Starting a backup job."
after_backup:
after_everything:
- echo "Backup created."
on_error:
- echo "Error while creating a backup."
healthchecks:
ping_url: ${BORG_HEALTHCHECK_URL}

103
entry.sh
Wyświetl plik

@ -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

Wyświetl plik

@ -1,6 +1,5 @@
--extra-index-url https://dl.cloudsmith.io/public/borgmatic-collective/borgmatic/python/simple/
apprise==1.6.0
borgbackup==1.2.6
borgmatic==1.8.4
borgbackup==1.2.8
borgmatic[apprise]==1.8.11
llfuse==1.5.0

Wyświetl plik

@ -0,0 +1 @@
oneshot

Wyświetl plik

@ -0,0 +1 @@
# This file doesn't do anything, it's just the end of the downstream image init process

Wyświetl plik

@ -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

Wyświetl plik

@ -0,0 +1 @@
oneshot

Wyświetl plik

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-custom-packages/run

Wyświetl plik

@ -0,0 +1,10 @@
#!/command/with-contenv bash
if test "$1" -eq 256 ; then
e=$((128 + $2))
else
e="$1"
fi
echo "Received exit code $e."
echo "$e" > /run/s6-linux-init-container-results/exitcode

Wyświetl plik

@ -0,0 +1,122 @@
#!/command/with-contenv bash
# Version variables
borgver=$(borg --version)
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" ]]; 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"
echo "# Cron disabled" > /etc/crontabs/root
echo "Cron is now disabled"
# Apply default or custom cron if $CRON is unset or set (not null):
elif [[ -v CRON ]]; then
CRON="${CRON:-"0 1 * * *"}"
CRON_COMMAND="${CRON_COMMAND:-"borgmatic --stats -v 0 2>&1"}"
echo "$CRON $CRON_COMMAND" > /etc/crontabs/root
echo "Applying custom cron"
# If nothing is set, revert to default behaviour
else
echo "Applying crontab.txt"
crontab /etc/borgmatic.d/crontab.txt
fi
# Apply extra cron if it's set
if [ -v EXTRA_CRON ]
then
echo "$EXTRA_CRON" >> /etc/crontabs/root
fi
# Current crontab var
crontab=$(crontab -l)
# Output cron settings to console
echo -e "Cron job set as: \n$crontab\n"
# Start Cron
exec /usr/sbin/crond -f -L /dev/stdout

Wyświetl plik

@ -0,0 +1 @@
longrun