mirror of
https://github.com/sstent/containers.git
synced 2026-01-25 16:41:51 +00:00
adding auto restore of DB
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
ARG RELEASE=latest
|
ARG RELEASE=latest
|
||||||
RUN apk add --no-cache --virtual .run-deps rsync openssh tzdata curl ca-certificates flock bash tar wget && rm -rf /var/cache/apk/*
|
RUN apk add --no-cache --virtual .run-deps rsync openssh tzdata curl ca-certificates flock bash tar wget unzip && rm -rf /var/cache/apk/*
|
||||||
RUN echo $RELEASE
|
RUN echo $RELEASE
|
||||||
RUN wget -P /tmp https://github.com/benbjohnson/litestream/releases/download/${RELEASE}/litestream-${RELEASE}-linux-arm7-static.tar.gz && \
|
RUN wget -P /tmp https://github.com/benbjohnson/litestream/releases/download/${RELEASE}/litestream-${RELEASE}-linux-arm7-static.tar.gz && \
|
||||||
tar -C /usr/local/bin/ -xzvf /tmp/litestream-${RELEASE}-linux-arm7-static.tar.gz
|
tar -C /usr/local/bin/ -xzvf /tmp/litestream-${RELEASE}-linux-arm7-static.tar.gz
|
||||||
|
|||||||
@@ -30,7 +30,23 @@ if [ "$NOMAD_TASK_NAME" == "init" ]; then
|
|||||||
|
|
||||||
|
|
||||||
echo "Starting DB Restore"
|
echo "Starting DB Restore"
|
||||||
/usr/local/bin/litestream restore -config /local/litestream.yml /config/${DB_NAME}
|
if /usr/local/bin/litestream restore -config /local/litestream.yml /config/${DB_NAME}; then
|
||||||
|
echo "Restore of ${DB_NAME} Succeeded: "
|
||||||
|
else
|
||||||
|
echo "Restore of ${DB_NAME} failed"
|
||||||
|
unset -v latest
|
||||||
|
for file in "/configbackup/Backups/scheduled"/*; do
|
||||||
|
[[ $file -nt $latest ]] && latest=$file
|
||||||
|
done
|
||||||
|
for file in "/configbackup/Backups/manual"/*; do
|
||||||
|
[[ $file -nt $latest ]] && latest=$file
|
||||||
|
done
|
||||||
|
echo "Restoring $latest"
|
||||||
|
unzip -o $latest -d /config
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
chown ${PUID:-1000}:${PGID:-1000} /config/*.db*
|
chown ${PUID:-1000}:${PGID:-1000} /config/*.db*
|
||||||
if [ -n "$DBCHMOD" ]; then
|
if [ -n "$DBCHMOD" ]; then
|
||||||
chmod ${DBCHMOD} /config/${DB_NAME}.db;
|
chmod ${DBCHMOD} /config/${DB_NAME}.db;
|
||||||
|
|||||||
Reference in New Issue
Block a user