-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2169ab4
commit 73bcd2e
Showing
5 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM alpine:latest | ||
|
||
LABEL maintainer="Sorena Sarabadani <[email protected]>" | ||
|
||
ENV MC_HOST_SOURCE **None** | ||
ENV MC_HOST_DESTINATION **None** | ||
ENV SCHEDULE **None** | ||
|
||
ADD . . | ||
|
||
RUN sh setup.sh && rm setup.sh | ||
|
||
CMD ["sh", "run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg | ||
[license-url]: https://github.com/fandoghpaas/minio-backup-s3/blob/master/LICENSE | ||
|
||
[docker-image]: https://img.shields.io/docker/pulls/fandoghpaas/minio-backup-s3.svg | ||
[docker-url]: https://hub.docker.com/r/fandoghpaas/minio-backup-s3/ | ||
|
||
# MinIO Backup S3 | ||
`minio-backup-s3` is a service giving you ability to mirror entities from `SOURCE OBJECT STORAGE` to `DESTINATION OBJECT STORAGE`. | ||
|
||
## Docker | ||
|
||
```sh | ||
$ docker run -e MC_HOST_SOURCE=https://<Access Key>:<Secret Key>@<YOUR-S3-ENDPOINT> -e MC_HOST_DESTINATION=https://<Access Key>:<Secret Key>@<YOUR-S3-ENDPOINT> fandoghpaas/minio-backup-s3:<IMAGE_VERSION> | ||
``` | ||
|
||
|
||
## [Fandogh PaaS](https://docs.fandogh.cloud) Manifest | ||
Copy below manifest in a YAML file and enter `fandogh service apply -f <FILE_NAME>.yml` | ||
``` | ||
kind: InternalService | ||
name: minio-backup | ||
spec: | ||
image: _/fandoghpaas/minio-backup-s3:1.0.0 | ||
image_pull_policy: Always | ||
env: | ||
- name: MC_HOST_SOURCE | ||
value: http://<Access Key>:<Secret Key>@<source-minio-service-name> | ||
- name: MC_HOST_DESTINATION | ||
value: http://<Access Key>:<Secret Key>@<destination-minio-service-name> | ||
``` | ||
|
||
## Variable Table | ||
|
||
> **Before deployment** value of `variables` mentioned in this table should be overwritten with values of your choice. | ||
|Variable | Description | | ||
|--- |--- | | ||
|**MC_HOST_SOURCE** | Choose source MinIO endpoint url | ||
|**MC_HOST_DESTINATION** | Choose destination MinIO endpoint url | ||
|**SCHEDULE** | backup schedule time for cronjob, see explanations below | ||
|
||
|
||
## SCHEDULE | ||
You can set the `SCHEDULE` environment variable like `-e SCHEDULE="@daily"` or `-e SCHEDULE="0 0 */4 * * *"` to run the backup automatically. | ||
|
||
> If you don't enter SCHEDULE env, container will perform its actions only one time and terminate! | ||
More information about the scheduling can be found [here](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#! /bin/sh | ||
|
||
set -e | ||
|
||
if [ "${MC_HOST_SOURCE}" == "**None**" ]; then | ||
echo "Error: You did not set the MC_HOST_SOURCE environment variable." | ||
exit 1 | ||
fi | ||
|
||
if [ "${MC_HOST_DESTINATION}" == "**None**" ]; then | ||
echo "Error: You did not set the MC_HOST_SOURCE environment variable." | ||
exit 1 | ||
fi | ||
|
||
mirror_s3 () { | ||
SOURCE_STORAGE=$1 | ||
DESTINATION_STORAGE=$2 | ||
|
||
echo "Mirroring buckets from ${SOURCE_STORAGE} to ${DESTINATION_STORAGE}..." | ||
|
||
./mc mirror SOURCE DESTINATION | ||
|
||
if [ $? != 0 ]; then | ||
>&2 echo "Error in migarating files from ${SOURCE_STORAGE} to ${DESTINATION_STORAGE}!" | ||
fi | ||
|
||
} | ||
|
||
mirror_s3 $MC_HOST_SOURCE $MC_HOST_SOURCE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#! /bin/sh | ||
|
||
set -e | ||
|
||
if [ "${SCHEDULE}" = "**None**" ]; then | ||
sh backup.sh | ||
else | ||
exec go-cron "$SCHEDULE" /bin/sh backup.sh | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#! /bin/sh | ||
|
||
# exit if a command fails | ||
set -e | ||
|
||
apk update | ||
|
||
#install minio mc | ||
apk add wget | ||
wget https://dl.min.io/client/mc/release/linux-amd64/mc | ||
chmod +x mc | ||
apk del wget | ||
|
||
# install go-cron | ||
apk add curl | ||
curl -L --insecure https://github.com/odise/go-cron/releases/download/v0.0.6/go-cron-linux.gz | zcat > /usr/local/bin/go-cron | ||
chmod u+x /usr/local/bin/go-cron | ||
apk del curl | ||
|
||
# cleanup | ||
rm -rf /var/cache/apk/* |