diff --git a/docs/arguments.md b/docs/arguments.md index f66a9530..671770e8 100644 --- a/docs/arguments.md +++ b/docs/arguments.md @@ -191,16 +191,13 @@ Useful when using [Custom rsync Arugments](#custom-rsync-arguments) USE_DEFAULT_RSYNC_ARGS=false ``` +🔄 This is the same action as the [Use Default rsync Arguments](./labels.md#use-default-rsync-arguments) label, but applied globally. + ## Custom rsync Arguments Apply custom `rsync` args (in addition to the [default](#use-default-rsync-arguments) args) > **Default**: *empty* (no custom rsync args will be applied) -The `RSYNC_CUSTOM_ARGS` will be inserted after the `$DEFAULT_RSYNC_ARGS` as shown: -```bash -rsync $DEFAULT_RSYNC_ARGS $RSYNC_CUSTOM_ARGS $src_dir/ $dest_dir/ -``` - There are many `rsync` arguments and customizations that be be used here. === "Example 1" @@ -209,5 +206,13 @@ There are many `rsync` arguments and customizations that be be used here. RSYNC_CUSTOM_ARGS=--exclude='*.log' --exclude='*.txt' ``` +The `RSYNC_CUSTOM_ARGS` will be inserted after the `$DEFAULT_RSYNC_ARGS` as shown: +```bash +rsync $DEFAULT_RSYNC_ARGS $RSYNC_CUSTOM_ARGS $src_dir/ $dest_dir/ +``` + + + +🔄 This is the same action as the [Custom rsync Arguments](./labels.md#custom-rsync-arguments) label, but applied globally.

diff --git a/docs/labels.md b/docs/labels.md index c981789a..6747516d 100644 --- a/docs/labels.md +++ b/docs/labels.md @@ -128,7 +128,7 @@ nautical-backup.enable=true With this label set to `false`, the container will not be stopped before performing a backup. -> **Default If Missing**: true (container ==will== be stopped before backup). +> **Default If Missing**: true (container ^^will^^ be stopped before backup). ```properties nautical-backup.stop-before-backup=false @@ -173,4 +173,38 @@ By default, Nautical will create destination directory that is the same name as nautical-backup.override-destination-dir=new_folder_name ``` -🔄 This is the same action as the [Override Destination Directory](./arguments.md#override-destination-directory) variable, but applied only to this container. \ No newline at end of file +🔄 This is the same action as the [Override Destination Directory](./arguments.md#override-destination-directory) variable, but applied only to this container. + +## Use Default rsync Arguments +Use the default `rsync` arguemnts `-raq` (recursive, archive, quiet) + +Useful when using [Custom rsync Arugments](#custom-rsync-arguments) + +> **Default**: *none* (use global setting) + +```properties +nautical-backup.use-default-rsync-args=false +``` + +!!! note "This label will *override* the global setting applied through [Enviornment Variables](./arguments.md)" + * A value of `true` will use the default rsync arguments regardless of the global setting. + * A value of `false` will ^^**not**^^ use the default rsync arguments regardless of the global setting. + * Not setting the label value will use the [global setting](./arguments.md#custom-rsync-arguments) + +🔄 Not setting a label is the same action as the [Use Default rsync Arguments](./arguments.md#use-default-rsync-arguments) variable, but applied only to this container. + +## Custom rsync Arguments +Apply custom `rsync` args (in addition to the [default](#use-default-rsync-arguments) args) + +> **Default**: *empty* (use global setting) + +```properties +nautical-backup.rsync-custom-args=--exclude='*.log' --exclude='*.txt' +``` + +!!! note "This label will *override* the global setting applied through [Enviornment Variables](./arguments.md)" + * *Any value* will override the global rsync arguemnts configured through [global settings](./arguments.md#custom-rsync-arguments). + * A (empty) value of `"nautical-backup.rsync-custom-args="` will ^^cancel^^ any [global setting](./arguments.md#custom-rsync-arguments) for this container only. + * Not setting the label value will use the [global setting](./arguments.md#custom-rsync-arguments). + +🔄 Not setting a label is the same action as the [Custom rsync Arguments](./arguments.md#custom-rsync-arguments) variable, but applied only to this container. \ No newline at end of file diff --git a/pkg/backup.sh b/pkg/backup.sh index c10d1607..b3b49703 100644 --- a/pkg/backup.sh +++ b/pkg/backup.sh @@ -53,6 +53,7 @@ if [ "$REPORT_FILE" = "true" ]; then echo "Backup Report - $(date)" >"$DEST_LOCATION/$report_file" fi +DEFAULT_RSYNC_ARGS="-ahq" default_rsync_args="-ahq" if [ "$USE_DEFAULT_RSYNC_ARGS" = "false" ]; then default_rsync_args="" @@ -142,6 +143,20 @@ BackupContainer() { fi fi + if echo "$labels" | grep -q '"nautical-backup.use-default-rsync-args":"true"'; then + echo "Using default rsync args ($DEFAULT_RSYNC_ARGS) for $container" + default_rsync_args=$DEFAULT_RSYNC_ARGS + elif echo "$labels" | grep -q '"nautical-backup.use-default-rsync-args":"false"'; then + echo "Not using default rsync args ($DEFAULT_RSYNC_ARGS) for $container" + default_rsync_args="" + fi + + if echo "$labels" | grep -q '"nautical-backup.rsync-custom-args"'; then + new_custom_rsync_args=$(echo "$labels" | jq -r '.["nautical-backup.rsync-custom-args"]') + custom_args=$new_custom_rsync_args + echo "Using custom rsync args for $container" + fi + log_entry "Backing up $container data..." if [ "$LOG_RSYNC_COMMANDS" = "true" ]; then echo rsync $default_rsync_args $custom_args $src_dir/ $dest_dir/