「✨」 feat: finished borg backup
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
FROM scratch AS builder
|
||||
ADD alpine-minirootfs-3.21.2-x86_64.tar.gz /
|
||||
ADD docker/alpine/alpine-minirootfs-3.21.2-x86_64.tar.gz /
|
||||
|
||||
RUN apk add go
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
@ -9,10 +11,11 @@ COPY cmd /build/cmd
|
||||
COPY internal /build/internal
|
||||
|
||||
RUN cd /build \
|
||||
&& go build git.keyzox.me/42_adjoly/inception/cmd/borg-backup/entrypoint
|
||||
&& go build git.keyzox.me/42_adjoly/inception/cmd/borg-backup/entrypoint \
|
||||
&& go build git.keyzox.me/42_adjoly/inception/cmd/borg-backup/getpassphrase
|
||||
|
||||
FROM scratch
|
||||
ADD alpine-minirootfs-3.21.2-x86_64.tar.gz /
|
||||
ADD docker/alpine/alpine-minirootfs-3.21.2-x86_64.tar.gz /
|
||||
|
||||
RUN mkdir -p /backup \
|
||||
&& mkdir -p /source \
|
||||
@ -23,11 +26,12 @@ RUN apk add --no-cache borgbackup tzdata \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
COPY --from=builder /build/entrypoint /docker-entrypoint
|
||||
COPY docker/bonus/borg-backup/default-bak.sh /docker-backup.d
|
||||
COPY --from=builder /build/getpassphrase /bin/getpassphrase
|
||||
COPY docker/bonus/borg-backup/default-bak.sh /docker-backup.d/default-bak.sh
|
||||
|
||||
ENTRYPOINT [ "/docker-entrypoint" ]
|
||||
WORKDIR /
|
||||
|
||||
STOPSIGNAL SIGQUIT
|
||||
|
||||
CMD [ "crond", "-l", "${CRON_LOGLEVEL:-8}", "-f" ]
|
||||
CMD [ "crond", "-l", "8", "-f" ]
|
||||
|
@ -3,9 +3,9 @@
|
||||
set -e
|
||||
|
||||
# Define variables from environment
|
||||
REPO=${BORG_REPO}
|
||||
PASSPHRASE=${BORG_PASSPHRASE}
|
||||
SOURCE=${BORG_SOURCE}
|
||||
REPO=${BORG_REPO:-/backup}
|
||||
BORG_PASSPHRASE=$(getpassphrase)
|
||||
SOURCE=${BORG_SOURCE:-/source}
|
||||
COMPRESSION=${BORG_COMPRESS:-zstd}
|
||||
PRUNE_KEEP_DAILY=${BORG_PRUNE_KEEP_DAILY:-7}
|
||||
PRUNE_KEEP_WEEKLY=${BORG_PRUNE_KEEP_WEEKLY:-4}
|
||||
@ -13,19 +13,20 @@ PRUNE_KEEP_MONTHLY=${BORG_PRUNE_KEEP_MONTHLY:-6}
|
||||
EXCLUDE_PATTERNS=${BORG_EXCLUDE_PATTERNS:-}
|
||||
CHECK_LAST=${BORG_CHECK_LAST}
|
||||
|
||||
BAK_ARGS=--compression $COMPRESSION
|
||||
BAK_ARGS="--compression $COMPRESSION"
|
||||
|
||||
if [[ -z "$PASSPHRASE" ]]; then
|
||||
if [ -z "$BORG_PASSPHRASE" ]; then
|
||||
echo "Could not found passphrase"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n "$EXCLUDE_PATTERNS" ]]; then
|
||||
BAK_ARGS+=--exclude $EXCLUDE_PATTERNS
|
||||
if [ -n "$EXCLUDE_PATTERNS" ]; then
|
||||
BAK_ARGS="$BAK_ARGS --exclude $EXCLUDE_PATTERNS"
|
||||
fi
|
||||
|
||||
# Borg backup command
|
||||
borg create --stats $BAK_ARGS \
|
||||
$REPO::$(hostname)-$(date +%Y-%m-%d) $SOURCE
|
||||
$REPO::$(date +%Y-%m-%d) $SOURCE
|
||||
|
||||
# Borg prune command
|
||||
|
||||
@ -35,11 +36,11 @@ borg prune --list $REPO --keep-daily=$PRUNE_KEEP_DAILY --keep-weekly=$PRUNE_KEEP
|
||||
# Borg check command
|
||||
CHECK_ARGS=""
|
||||
|
||||
if [[ -n "$CHECK_LAST" ]]; then
|
||||
CHECK_ARGS+=--last $CHECK_LAST
|
||||
if [ -n "$CHECK_LAST" ]; then
|
||||
CHECK_ARGS="$CHECK_ARGS --last $CHECK_LAST"
|
||||
fi
|
||||
if [[ -n "$CHECK_DATA" ]]; then
|
||||
CHECK_ARGS+=--verify-data
|
||||
if [ -n "$CHECK_DATA" ]; then
|
||||
CHECK_ARGS="$CHECK_ARGS --verify-data"
|
||||
fi
|
||||
|
||||
borg check $CHECK_ARGS $REPO
|
||||
|
Reference in New Issue
Block a user