From 1a200567ebf8d840f7a0dcd82d2b3a27ef9486e2 Mon Sep 17 00:00:00 2001 From: 10 <2408212-10@users.noreply.gitlab.com> Date: Fri, 24 May 2019 01:40:45 +0200 Subject: [PATCH] Allow to run /backup.sh script as standalone fixes #5 --- README.md | 4 ++-- entrypoint.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) mode change 100644 => 100755 entrypoint.sh diff --git a/README.md b/README.md index 7dc858b..ce2d441 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,12 @@ You can use the crontab of your host to schedule the backup and the container wi Example using the integrated Backup script. You can use Environment variables for database and backup location ```sh -docker run --rm --volumes-from=bitwarden bruceforce/bw_backup /backup.sh +docker run --rm --volumes-from=bitwarden bruceforce/bw_backup manual ``` If you want to run the sqlite commands manually you can use the following command ```sh -docker run --rm --volumes-from=bitwarden bruceforce/bw_backup sqlite3 $DB_FILE ".backup $BACKUP_FILE" +docker run --rm --volumes-from=bitwarden --entrypoint sqlite3 bruceforce/bw_backup $DB_FILE ".backup $BACKUP_FILE" ``` ## Environment variables diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 index d88fcf7..3aa14fd --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,9 +1,23 @@ #!/bin/sh +# vim: tabstop=2 shiftwidth=2 expandtab #set -ux BACKUP_CMD="/sbin/su-exec ${UID}:${GID} /app/backup.sh" +# For compatibility reasons +if [ "$1" = "/backup.sh" ]; then + >&2 echo "Using /backup.sh is deprecated and will be removed in future versions! Please use \`manual\` as arugment instead" + $BACKUP_CMD +fi + +# Just run the backup script +if [ "$1" = "manual" ]; then + $BACKUP_CMD +fi +exit 0 + +# Initialize cron echo "Running as $(id)" if [ "$(id -u)" -eq 0 ] && [ "$(grep -c "$BACKUP_CMD" "$CRONFILE")" -eq 0 ]; then echo "Initalizing..."