Browse Source

Merge pull request #100 from schickling/add-s3cmd-schedule

Add s3cmd scheduling for automatic backup
pull/101/head
Johannes Schickling 7 years ago
committed by GitHub
parent
commit
d572209166
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      s3cmd/Dockerfile
  2. 11
      s3cmd/README.md
  3. 12
      s3cmd/install.sh
  4. 11
      s3cmd/run.sh

8
s3cmd/Dockerfile

@ -1,9 +1,13 @@
FROM alpine:3.1
FROM alpine:3.7
LABEL maintainer="Johannes Schickling <schickling.j@gmail.com>"
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"]

11
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.

12
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

11
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
Loading…
Cancel
Save