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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
35 additions and
7 deletions
-
s3cmd/Dockerfile
-
s3cmd/README.md
-
s3cmd/install.sh
-
s3cmd/run.sh
|
|
@ -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"] |
|
|
@ -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. |
|
|
@ -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 |
|
|
@ -0,0 +1,11 @@ |
|
|
|
#! /bin/sh |
|
|
|
|
|
|
|
set -e |
|
|
|
|
|
|
|
echo "Running s3cmd ..." |
|
|
|
|
|
|
|
if [ "${SCHEDULE}" = "**None**" ]; then |
|
|
|
s3cmd "$@" |
|
|
|
else |
|
|
|
exec go-cron "$SCHEDULE" s3cmd "$@" |
|
|
|
fi |