Browse Source

Add allowFailure option for destinations

master
Drew Short 4 years ago
parent
commit
80c1116e5e
  1. 1
      README.md
  2. 25
      assets/out
  3. 2
      tag

1
README.md

@ -72,6 +72,7 @@ It's highly recommended to use secrets mangement to avoid storing sensitive cred
* `link`: Optional. Create a link to the resource if possible. Default `false`
* `linkFilter`: Optional. A find filter on the source directory for files to generate links to. Default `-maxdepth 1 -type f`
* `args`: Optional. An array of additional arguments to pass to rclone.
* `allowFailure`: Optional. Allow this destination to fail without failing the job. Default `false`
#### Example

25
assets/out

@ -78,6 +78,7 @@ for destination in $destinations; do
rclone_args=$(_jq '.args // [] | join(" ")')
rclone_link=$(_jq '.link // "false"')
rclone_link_find_filter=$(_jq '.linkFilter // "-maxdepth 1 -type f"')
rclone_allow_failure=$(_jq '.allowFailure // "false"')
echo "Destination: $rclone_destination"
echo "Destination subdir file: ${rclone_destination_subdir_file}"
@ -86,6 +87,11 @@ for destination in $destinations; do
echo "Additonal args: ${rclone_args}"
echo "Generate link: ${rclone_link}"
echo "Link find filter: ${rclone_link_find_filter}"
echo "Allow failure: ${rclone_allow_failure}"
if [[ "${rclone_allow_failure}" = "true" ]]; then
set +e
fi
rclone_destination_subdir=""
if [ -n "$rclone_destination_subdir_file" ]; then
@ -101,11 +107,21 @@ for destination in $destinations; do
echo "Target: ${rclone_target}"
# shellcheck disable=2086
rclone copy "${rclone_source}" "${rclone_target}" --size-only --progress --stats=2s ${rclone_args}
copy_rc=$?
if [[ "${rclone_allow_failure}" = "true" && $copy_rc -gt 0 ]]; then
echo "Rclone copy failed. Switching to next destination."
continue
fi
if [[ "$rclone_dedupe" == "true" ]]; then
echo "Running Dedupe for: ${rclone_target}"
# shellcheck disable=2086
rclone dedupe --dedupe-mode "${rclone_dedupe_mode}" "${rclone_target}" --progress --stats=2s ${rclone_args}
dedupe_rc=$?
if [[ "${rclone_allow_failure}" = "true" && $dedupe_rc -gt 0 ]]; then
echo "Rclone dedupe failed. Switching to next destination."
continue
fi
fi
if [[ "${rclone_link}" == "true" ]]; then
@ -118,10 +134,19 @@ for destination in $destinations; do
rclone_target_file="${rclone_target}/${remote_file}"
echo "Generating Link for: ${rclone_target_file}"
file_link=$(rclone link "${rclone_target_file}")
link_rc=$?
if [[ "${rclone_allow_failure}" = "true" && $link_rc -gt 0 ]]; then
echo "Rclone linking failed. Switching to next target."
continue
fi
file_links+=( "${rclone_target_file}" "${file_link}" )
done
fi
if [[ "${rclone_allow_failure}" = "true" ]]; then
set -e
fi
echo "rclone job complete for ${rclone_source} -> ${rclone_target}"
done

2
tag

@ -1 +1 @@
1.0.0
1.1.0
Loading…
Cancel
Save