├── run.sh ├── Dockerfile ├── setup.sh ├── backup.sh ├── LICENSE └── README.md /run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | if [ "${SCHEDULE}" = "**None**" ]; then 6 | sh backup.sh 7 | else 8 | exec go-cron "$SCHEDULE" /bin/sh backup.sh 9 | fi 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | LABEL maintainer="Sorena Sarabadani " 4 | 5 | ENV MC_HOST_SOURCE **None** 6 | ENV MC_HOST_DESTINATION **None** 7 | ENV SCHEDULE **None** 8 | 9 | ADD . . 10 | 11 | RUN sh setup.sh && rm setup.sh 12 | 13 | CMD ["sh", "run.sh"] 14 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # exit if a command fails 4 | set -e 5 | 6 | apk update 7 | 8 | #install minio mc 9 | apk add wget 10 | wget https://dl.min.io/client/mc/release/linux-amd64/mc 11 | chmod +x mc 12 | apk del wget 13 | 14 | # install go-cron 15 | apk add curl 16 | curl -L --insecure https://github.com/odise/go-cron/releases/download/v0.0.6/go-cron-linux.gz | zcat > /usr/local/bin/go-cron 17 | chmod u+x /usr/local/bin/go-cron 18 | apk del curl 19 | 20 | # cleanup 21 | rm -rf /var/cache/apk/* 22 | -------------------------------------------------------------------------------- /backup.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | if [ "${MC_HOST_SOURCE}" == "**None**" ]; then 6 | echo "Error: You did not set the MC_HOST_SOURCE environment variable." 7 | exit 1 8 | fi 9 | 10 | if [ "${MC_HOST_DESTINATION}" == "**None**" ]; then 11 | echo "Error: You did not set the MC_HOST_SOURCE environment variable." 12 | exit 1 13 | fi 14 | 15 | mirror_s3 () { 16 | SOURCE_STORAGE=$1 17 | DESTINATION_STORAGE=$2 18 | 19 | echo "Mirroring buckets from ${SOURCE_STORAGE} to ${DESTINATION_STORAGE}..." 20 | 21 | ./mc --insecure mirror SOURCE DESTINATION 22 | 23 | if [ $? != 0 ]; then 24 | >&2 echo "Error in migarating files from ${SOURCE_STORAGE} to ${DESTINATION_STORAGE}!" 25 | fi 26 | 27 | } 28 | 29 | mirror_s3 $MC_HOST_SOURCE $MC_HOST_DESTINATION 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Fandogh PaaS 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![MIT license][license-image]][license-url] 2 | [![Docker][docker-image]][docker-url] 3 | 4 | [license-image]: https://img.shields.io/badge/license-MIT-blue.svg 5 | [license-url]: https://github.com/fandoghpaas/minio-backup-s3/blob/master/LICENSE 6 | 7 | [docker-image]: https://img.shields.io/docker/pulls/fandoghpaas/minio-backup-s3.svg 8 | [docker-url]: https://hub.docker.com/r/fandoghpaas/minio-backup-s3/ 9 | 10 | # MinIO Backup S3 11 | `minio-backup-s3` is a service giving you ability to mirror entities from `SOURCE OBJECT STORAGE` to `DESTINATION OBJECT STORAGE`. 12 | 13 | ## Docker 14 | 15 | ```sh 16 | $ docker run -e MC_HOST_SOURCE=https://:@ -e MC_HOST_DESTINATION=https://:@ fandoghpaas/minio-backup-s3: 17 | ``` 18 | 19 | 20 | ## [Fandogh PaaS](https://docs.fandogh.cloud) Manifest 21 | Copy below manifest in a YAML file and enter `fandogh service apply -f .yml` 22 | ``` 23 | kind: InternalService 24 | name: minio-backup 25 | spec: 26 | image: fandoghpaas/minio-backup-s3:1.1.0 27 | image_pull_policy: Always 28 | env: 29 | - name: MC_HOST_SOURCE 30 | value: http://:@ 31 | - name: MC_HOST_DESTINATION 32 | value: http://:@ 33 | ``` 34 | 35 | ## Variable Table 36 | 37 | > **Before deployment** value of `variables` mentioned in this table should be overwritten with values of your choice. 38 | 39 | |Variable | Description | 40 | |--- |--- | 41 | |**MC_HOST_SOURCE** | Choose source MinIO endpoint url 42 | |**MC_HOST_DESTINATION** | Choose destination MinIO endpoint url 43 | |**SCHEDULE** | backup schedule time for cronjob, see explanations below 44 | 45 | 46 | ## SCHEDULE 47 | You can set the `SCHEDULE` environment variable like `-e SCHEDULE="@daily"` runs every day at the same time that it was started or `-e SCHEDULE="0 0 */4 * * *"` to run the backup automatically every 4 hours or any other cron time that you prefer. 48 | 49 | > If you don't enter SCHEDULE env, container will perform its actions only one time and terminate! 50 | 51 | More information about the scheduling can be found [here](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules). 52 | 53 | --------------------------------------------------------------------------------