44. ${BASE} /functions
55
66# Check for the required input
7- if [ -z " ${PROVIDER } " ]; then
8- echo " You have to define the bucket provider"
7+ if [ -z " ${PROVIDER_SRC } " ]; then
8+ echo " You have to define the source bucket provider"
99 exit 12
1010fi
11- if [ " ${PROVIDER_LOWER} " != " aws" ] && [ " ${PROVIDER_LOWER} " != " gcs" ] && [ " ${PROVIDER_LOWER} " != " minio" ]; then
11+ if [ -z " ${PROVIDER_DST} " ]; then
12+ echo " You have to define the destination bucket provider"
13+ exit 12
14+ fi
15+ if [ " ${PROVIDER_SRC_LOWER} " != " aws" ] && [ " ${PROVIDER_SRC_LOWER} " != " gcs" ] && [ " ${PROVIDER_SRC_LOWER} " != " minio" ]; then
1216 echo " You have to define a valid bucket provider (aws, gcs, minio)"
1317 exit 12
1418fi
15- if [ " ${PROVIDER_LOWER} " = " minio" ] && [ -z " ${BUCKET_SRC_ENDPOINT} " ]; then
19+ if [ " ${PROVIDER_DST_LOWER} " != " aws" ] && [ " ${PROVIDER_DST_LOWER} " != " gcs" ] && [ " ${PROVIDER_DST_LOWER} " != " minio" ]; then
20+ echo " You have to define a valid bucket provider (aws, gcs, minio)"
21+ exit 12
22+ fi
23+ if [ " ${PROVIDER_SRC_LOWER} " = " minio" ] && [ -z " ${BUCKET_SRC_ENDPOINT} " ]; then
1624 echo " You have to define the source bucket endpoint"
1725 exit 12
1826fi
1927if [ -z " ${BUCKET_SRC} " ]; then
2028 echo " You have to define the source bucket name"
2129 exit 12
2230fi
23- if [ " ${PROVIDER_LOWER } " = " minio" ] && [ -z " ${BUCKET_DST_ENDPOINT} " ]; then
31+ if [ " ${PROVIDER_DST_LOWER } " = " minio" ] && [ -z " ${BUCKET_DST_ENDPOINT} " ]; then
2432 echo " You have to define the destination bucket endpoint"
2533 exit 12
2634fi
@@ -34,7 +42,8 @@ echo "All the required inputs are present. Go on with the real job."
3442
3543echo " Copy the file from the source bucket to the destination bucket."
3644format_string " Parameters:" " g"
37- echo " $( format_string " Provider:" " bold" ) ${PROVIDER_LOWER} "
45+ echo " $( format_string " Src Provider:" " bold" ) ${PROVIDER_SRC_LOWER} "
46+ echo " $( format_string " Dst Provider:" " bold" ) ${PROVIDER_DST_LOWER} "
3847echo " $( format_string " Src:" " bold" ) ${BUCKET_SRC} /${FILE_SRC} "
3948echo " $( format_string " Dst:" " bold" ) ${BUCKET_DST} /${FILE_DST} "
4049if [ -z " ${FILE_SRC} " ] && [ -z " ${FILE_DST} " ]; then
@@ -46,15 +55,7 @@ elif [ -z "${FILE_DST}" ]; then
4655fi
4756echo " $( format_string " ACL:" " bold" ) ${ACL} "
4857
49- if [ " ${PROVIDER_LOWER} " = " aws" ]; then
50- echo " rclone_aws sync :s3://${BUCKET_SRC} /${FILE_SRC} :s3://${BUCKET_DST} /${FILE_DST} "
51- rclone_aws sync :s3://${BUCKET_SRC} /${FILE_SRC} :s3://${BUCKET_DST} /${FILE_DST}
52- EXIT_RCLONE=$?
53- elif [ " ${PROVIDER_LOWER} " = " gcs" ]; then
54- echo " rclone_gcs sync :gcs://${BUCKET_SRC} /${FILE_SRC} :gcs://${BUCKET_SRC} /${FILE_DST} "
55- rclone_gcs sync :gcs://${BUCKET_SRC} /${FILE_SRC} :gcs://${BUCKET_SRC} /${FILE_DST}
56- EXIT_RCLONE=$?
57- elif [ " ${PROVIDER_LOWER} " = " minio" ]; then
58+ if [ " ${PROVIDER_LOWER} " = " minio" ]; then
5859 # Wait for source minio service
5960 WAIT_ENDPOINT=$( remove_http_proto " ${BUCKET_SRC_ENDPOINT} " )
6061 debug " Wait for source minio service (${WAIT_ENDPOINT} , timeout ${TIMEOUT_BUCKET_SRC} seconds)."
@@ -97,12 +98,12 @@ elif [ "${PROVIDER_LOWER}" = "minio" ]; then
9798 exit 13
9899 fi
99100 done
100-
101- echo " rclone_minio_multi sync src://${BUCKET_SRC} /${FILE_SRC} dst://${BUCKET_DST} /${FILE_DST} "
102- rclone_minio_multi sync src://${BUCKET_SRC} /${FILE_SRC} dst://${BUCKET_DST} /${FILE_DST}
103- EXIT_RCLONE=$?
104101fi
105102
103+ echo " rclone_generic sync src://${BUCKET_SRC} /${FILE_SRC} dst://${BUCKET_DST} /${FILE_DST} "
104+ rclone_generic sync src://${BUCKET_SRC} /${FILE_SRC} dst://${BUCKET_DST} /${FILE_DST}
105+ EXIT_RCLONE=$?
106+
106107if [ ${EXIT_RCLONE} -ne 0 ]; then
107108 echo " Something went wrong during the copy of files."
108109 exit ${EXIT_RCLONE}
0 commit comments