From 9aea504ab8ebd7e80ba39540cae25dfa6136129e Mon Sep 17 00:00:00 2001 From: James Tufarelli <8152401+Minituff@users.noreply.github.com> Date: Thu, 12 Oct 2023 11:23:08 -0700 Subject: [PATCH] Dev (#20) * Typo fix * Reduce docker image size --- Dockerfile | 8 ++++---- docs/advanced.md | 2 +- docs/arguments.md | 2 +- pkg/backup.sh | 15 +++++++++++++-- pkg/entry.sh | 8 ++++++++ 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index c8939e30..5751d603 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # Use base docker image. Contains the docker commands we need to start and stop containers -FROM docker:24.0.6 +FROM docker:24.0.6-cli # Install dependencies -RUN apk add bash rsync tzdata +RUN apk add bash rsync tzdata dos2unix # Copy all necessary files into the container (from /pkg in the repository to /app in the container) COPY pkg app @@ -11,10 +11,10 @@ COPY pkg app RUN mv app/entry.sh /entry.sh # Make the script executable -RUN chmod +x app/backup.sh +RUN chmod +x app/backup.sh && dos2unix app/backup.sh # Make the entry script executable -RUN chmod +x entry.sh +RUN chmod +x entry.sh && dos2unix entry.sh # Set default timezone ENV TZ=Etc/UTC diff --git a/docs/advanced.md b/docs/advanced.md index 0aab17c3..af1b9b45 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -1,4 +1,4 @@ -These exmaples used Docker Compose syntax. See the [Installation section](./installation.md#docker-compose-example) to fit them into your configutation. +These exmaples used Docker Compose syntax. See the [Installation section](./installation.md#docker-compose-example) to fit them into your configuration. ## Alternative Source Directories Don't have all your container volumes in the same directory? That's okay, we can use Docker volume mappings to help. diff --git a/docs/arguments.md b/docs/arguments.md index 74cbfdb3..1d8f4668 100644 --- a/docs/arguments.md +++ b/docs/arguments.md @@ -1,6 +1,6 @@ Nautical provides configuration in the form of Docker enviornment variables. -See the [Installation Section](./installation.md), which contains a few examples of applying envrionment variables. +See the [Installation Section](./installation.md), which contains a few examples of applying enviornment variables. ## Time Zone diff --git a/pkg/backup.sh b/pkg/backup.sh index 8a7fa0dc..8c6d97c2 100644 --- a/pkg/backup.sh +++ b/pkg/backup.sh @@ -56,6 +56,13 @@ if [ "$REPORT_FILE" = "true" ]; then fi +# Global variables to hold rsync arguments +custom_args="" +if [ ! -z "$RSYNC_CUSTOM_ARGS" ]; then + custom_args="$RSYNC_CUSTOM_ARGS" +fi + + # Get arguments: # -s = skips # -d = override DEST_LOCATION @@ -117,7 +124,9 @@ BackupContainer() { fi log_entry "Backing up $container data..." - rsync -ah -q --info=progress2 --exclude '*.log' $src_dir/ $dest_dir/ + # rsync -ah -q --info=progress2 --exclude '*.log' $src_dir/ $dest_dir/ + # echo rsync -ah -q $custom_args --info=progress2 $src_dir/ $dest_dir/ + rsync -ah -q --info=progress2 $src_dir/ $dest_dir/ 2>&1 >/dev/null if [ $? -ne 0 ]; then log_entry "Error copying data for container $container. Skipping backup for this container." @@ -168,4 +177,6 @@ for entry in $containers; do fi done -echo "Success. $containers_completed containers backed up!" \ No newline at end of file +containers_skipped=$((number_of_containers - containers_completed)) + +echo "Success. $containers_completed containers backed up! $containers_skipped skipped." \ No newline at end of file diff --git a/pkg/entry.sh b/pkg/entry.sh index 66df3cf8..b2aebe29 100644 --- a/pkg/entry.sh +++ b/pkg/entry.sh @@ -105,6 +105,14 @@ if [ "$REPORT_FILE" = "false" ]; then echo "REPORT_FILE: $REPORT_FILE" fi +# Set rsync custom arguments if specified +if [ ! -z "$RSYNC_CUSTOM_ARGS" ]; then + echo "RSYNC_CUSTOM_ARGS: $RSYNC_CUSTOM_ARGS" +fi + + + + if [ "$BACKUP_ON_START" = "true" ]; then echo "BACKUP_ON_START: $BACKUP_ON_START" bash ./app/backup.sh