From 7f585e3fd19ed1783771b2b4b5e498beba12db53 Mon Sep 17 00:00:00 2001 From: 1O <2408212-1O@users.noreply.gitlab.com> Date: Wed, 16 Sep 2020 19:17:41 +0200 Subject: [PATCH] Added ENV BACKUP_FILE_PERMISSIONS to set permissions of the backup file --- Dockerfile | 1 + README.md | 1 + backup.sh | 2 +- entrypoint.sh | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d6163c4..e923b32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ RUN apk add --no-cache \ ENV DB_FILE /data/db.sqlite3 ENV BACKUP_FILE /data/db_backup/backup.sqlite3 +ENV BACKUP_FILE_PERMISSIONS 600 ENV CRON_TIME "0 5 * * *" ENV TIMESTAMP false ENV UID 100 diff --git a/README.md b/README.md index df88114..788aad1 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ docker run --rm --volumes-from=bitwarden -v /tmp/myBackup:/myBackup --entrypoint | ----- | ----- | | DB_FILE | Path to the Bitwarden sqlite3 database *inside* the container | | BACKUP_FILE | Path to the desired backup location *inside* the container | +| BACKUP_FILE_PERMISSIONS | Sets the permissions of the backup file | | CRON_TIME | Cronjob format "Minute Hour Day_of_month Month_of_year Day_of_week Year" | | TIMESTAMP | Set to `true` to append timestamp to the `BACKUP_FILE` | | UID | User ID to run the cron job with | diff --git a/backup.sh b/backup.sh index 50d20ba..63c8167 100644 --- a/backup.sh +++ b/backup.sh @@ -15,7 +15,7 @@ else fi /usr/bin/sqlite3 $DB_FILE ".backup $FINAL_BACKUP_FILE" -if [ $? -eq 0 ] +if [ $? -eq 0 ] then echo "$(date "+%F %T") - Backup successfull" else diff --git a/entrypoint.sh b/entrypoint.sh index 17148ce..8a668e3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,7 +9,8 @@ BACKUP_CMD="/sbin/su-exec ${UID}:${GID} /app/backup.sh" if [ ! -d $(dirname "$BACKUP_FILE") ] then mkdir -p $(dirname "$BACKUP_FILE") - chown $UID:$GID $(dirname "$BACKUP_FILE") + chown -R $UID:$GID $(dirname "$BACKUP_FILE") + chmod -R "$BACKUP_FILE_PERMISSIONS" $(dirname "$BACKUP_FILE") fi # For compatibility reasons