Skip to content

Commit

Permalink
switch to rclone
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticroentgen committed Jan 24, 2024
1 parent 0e28c01 commit 6ef7db0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ EXPOSE 8081

# Install minio client
RUN echo "building for $ARCH"
RUN apk --no-cache add curl
RUN curl https://dl.min.io/client/mc/release/${ARCH}/mc --create-dirs -o /usr/bin/mc && \
chmod +x /usr/bin/mc
RUN apk --no-cache add curl rclone
#RUN curl https://dl.min.io/client/mc/release/${ARCH}/mc --create-dirs -o /usr/bin/mc && chmod +x /usr/bin/mc

COPY mirror-s3.sh /usr/bin
COPY rclone.conf.tmpl /etc
RUN chmod +x /usr/bin/mirror-s3.sh

ENTRYPOINT ["/usr/bin/mirror-s3.sh"]
13 changes: 5 additions & 8 deletions mirror-s3.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
echo "Generating rclone config..."
envsubst < /etc/rclone.conf.tmpl > /etc/rclone.conf

echo "Running rclone sync..."
DEBUG=""

if [[ "$MINIO_DEBUG" == "1" ]]; then
Expand All @@ -11,11 +15,4 @@ if [[ "$MINIO_OVERWRITE" == "1" ]]; then
OVERWRITE="--overwrite"
fi

echo "Adding S3 source..."
/usr/bin/mc alias set s3_source ${SOURCE_ENDPOINT} ${SOURCE_ACCESS_KEY} ${SOURCE_SECRET_KEY}

echo "Adding S3 destination..."
/usr/bin/mc alias set s3_destination ${DESTINATION_ENDPOINT} ${DESTINATION_ACCESS_KEY} ${DESTINATION_SECRET_KEY}

echo "Start mirror..."
/usr/bin/mc ${DEBUG} mirror ${OVERWRITE} ${MINIO_EXTRA_OPTS} s3_source/${SOURCE_BUCKET} s3_destination/${DESTINATION_BUCKET} && curl ${HEALTHCHECK_URL}
rclone sync sync_src/${SOURCE_BUCKET} sync_dst/${DESTINATION_BUCKET} && curl ${HEALTHCHECK_URL}
15 changes: 15 additions & 0 deletions rclone.conf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[sync_src]
type = s3
env_auth = false
access_key_id = ${SOURCE_ACCESS_KEY}
secret_access_key = ${SOURCE_SECRET_KEY}
region = us-east-1
endpoint = ${SOURCE_ENDPOINT}
location_constraint =
server_side_encryption =

[sync_dst]
type = b2
account = ${DESTINATION_ACCESS_KEY}
key = ${DESTINATION_SECRET_KEY}

0 comments on commit 6ef7db0

Please sign in to comment.