diff --git a/s3cmd/Dockerfile b/s3cmd/Dockerfile index 38cd0b9..4c3327f 100644 --- a/s3cmd/Dockerfile +++ b/s3cmd/Dockerfile @@ -1,9 +1,13 @@ -FROM alpine:3.1 +FROM alpine:3.7 LABEL maintainer="Johannes Schickling " ADD install.sh install.sh RUN sh install.sh && rm install.sh +ENV SCHEDULE **None** + +ADD run.sh /opt/s3cmd/run.sh + WORKDIR /s3 -ENTRYPOINT ["s3cmd"] +ENTRYPOINT ["/opt/s3cmd/run.sh"] diff --git a/s3cmd/README.md b/s3cmd/README.md index 765228e..fc4c8a4 100644 --- a/s3cmd/README.md +++ b/s3cmd/README.md @@ -1,12 +1,21 @@ # s3cmd Lightweight wrapper around s3cmd -## Usage +## Basic usage ```sh $ docker run -v $(pwd):/s3 schickling/s3cmd sync . s3://my-bucket ``` +## Environment variables + +- SCHEDULE backup schedule time, see explainatons below + +## Automatic Periodic Backups + +You can additionally set the SCHEDULE environment variable like -e SCHEDULE="@daily" to run the backup automatically. +More information about the scheduling can be found [here](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules). + ### `s3cmd` documentation See [here](http://s3tools.org/usage) for the documentation. diff --git a/s3cmd/install.sh b/s3cmd/install.sh index a16241b..72e6eb0 100644 --- a/s3cmd/install.sh +++ b/s3cmd/install.sh @@ -5,12 +5,16 @@ set -e # install s3cmd apk update -apk add python py-pip py-setuptools git ca-certificates +apk add --no-cache python py-pip py-setuptools git ca-certificates pip install python-magic git clone https://github.com/s3tools/s3cmd.git /tmp/s3cmd cd /tmp/s3cmd python setup.py install - -# cleanup apk del git -rm -rf /var/cache/apk/* /tmp/s3cmd +rm -rf /tmp/s3cmd + +# install go-cron +apk add --no-cache 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 diff --git a/s3cmd/run.sh b/s3cmd/run.sh new file mode 100755 index 0000000..2b6c886 --- /dev/null +++ b/s3cmd/run.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +set -e + +echo "Running s3cmd ..." + +if [ "${SCHEDULE}" = "**None**" ]; then + s3cmd "$@" +else + exec go-cron "$SCHEDULE" s3cmd "$@" +fi