Compare commits
11 Commits
1288239de3
...
d576a7f752
Author | SHA1 | Date |
---|---|---|
![]() |
d576a7f752 | |
![]() |
a6d878638b | |
![]() |
7bdb1a17b4 | |
![]() |
082e5188aa | |
![]() |
014b843a2c | |
![]() |
05dfe25557 | |
![]() |
957697dc1a | |
![]() |
f3d579a0e9 | |
![]() |
f19b3fa1ee | |
![]() |
4d18ac3fc8 | |
![]() |
9cb9e30ad7 |
|
@ -1,10 +1,11 @@
|
||||||
FROM alpine:3.6
|
FROM alpine:3.10
|
||||||
MAINTAINER Elementar Sistemas <contato@elementarsistemas.com.br>
|
label maintainer="Elementar Sistemas <contato@elementarsistemas.com.br>"
|
||||||
|
|
||||||
RUN apk --no-cache add bash py-pip && pip install awscli
|
RUN apk --no-cache add bash py3-pip && pip3 install --no-cache-dir awscli
|
||||||
ADD watch /watch
|
ADD watch /watch
|
||||||
|
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
|
|
||||||
|
ENV S3_SYNC_FLAGS "--delete"
|
||||||
ENTRYPOINT [ "./watch" ]
|
ENTRYPOINT [ "./watch" ]
|
||||||
CMD ["/data"]
|
CMD ["/data"]
|
||||||
|
|
23
README.md
23
README.md
|
@ -1,5 +1,11 @@
|
||||||
# docker-s3-volume
|
# docker-s3-volume
|
||||||
|
|
||||||
|
[](https://hub.docker.com/r/elementar/s3-volume)
|
||||||
|
[](https://hub.docker.com/r/elementar/s3-volume)
|
||||||
|
[](https://hub.docker.com/r/elementar/s3-volume)
|
||||||
|
[](https://hub.docker.com/r/elementar/s3-volume)
|
||||||
|
[](https://hub.docker.com/r/elementar/s3-volume)
|
||||||
|
|
||||||
Creates a Docker container that is restored and backed up to a directory on s3.
|
Creates a Docker container that is restored and backed up to a directory on s3.
|
||||||
You could use this to run short lived processes that work with and persist data to and from S3.
|
You could use this to run short lived processes that work with and persist data to and from S3.
|
||||||
|
|
||||||
|
@ -49,6 +55,15 @@ Any environment variable available to the `aws-cli` command can be used. see
|
||||||
http://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html for more
|
http://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html for more
|
||||||
information.
|
information.
|
||||||
|
|
||||||
|
### Configuring an endpoint URL
|
||||||
|
|
||||||
|
If you are using an S3-compatible service (such as Oracle OCI Object Storage), you may want to set the service's endpoint URL:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d --name my-data-container -e ENDPOINT_URL=... \
|
||||||
|
elementar/s3-volume /data s3://mybucket/someprefix
|
||||||
|
```
|
||||||
|
|
||||||
### Forcing a sync
|
### Forcing a sync
|
||||||
|
|
||||||
A final sync will always be performed on container shutdown. A sync can be
|
A final sync will always be performed on container shutdown. A sync can be
|
||||||
|
@ -69,6 +84,14 @@ docker run -d --name my-data-container \
|
||||||
elementar/s3-volume --force-restore /data s3://mybucket/someprefix
|
elementar/s3-volume --force-restore /data s3://mybucket/someprefix
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Deletion and sync
|
||||||
|
|
||||||
|
By default if there are files that are deleted in your local file system, those will be deleted remotely. If you wish to turn this off, set the environment variable `S3_SYNC_FLAGS` to an empty string:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d -e S3_SYNC_FLAGS="" elementar/s3-volume /data s3://mybucket/someprefix
|
||||||
|
```
|
||||||
|
|
||||||
### Using Compose and named volumes
|
### Using Compose and named volumes
|
||||||
|
|
||||||
Most of the time, you will use this image to sync data for another container.
|
Most of the time, you will use this image to sync data for another container.
|
||||||
|
|
12
watch
12
watch
|
@ -40,6 +40,12 @@ PROGNAME=$0
|
||||||
LOCAL=$1
|
LOCAL=$1
|
||||||
REMOTE=$2
|
REMOTE=$2
|
||||||
|
|
||||||
|
if [ "$ENDPOINT_URL" ]; then
|
||||||
|
AWS="aws --endpoint-url $ENDPOINT_URL"
|
||||||
|
else
|
||||||
|
AWS=aws
|
||||||
|
fi
|
||||||
|
|
||||||
function restore {
|
function restore {
|
||||||
if [ "$(ls -A $LOCAL)" ]; then
|
if [ "$(ls -A $LOCAL)" ]; then
|
||||||
if [[ ${FORCE_RESTORE:false} == 'true' ]]; then
|
if [[ ${FORCE_RESTORE:false} == 'true' ]]; then
|
||||||
|
@ -48,14 +54,14 @@ function restore {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "restoring $REMOTE => $LOCAL"
|
echo "restoring $REMOTE => $LOCAL"
|
||||||
if ! aws s3 sync "$REMOTE" "$LOCAL"; then
|
if ! $AWS s3 sync "$REMOTE" "$LOCAL"; then
|
||||||
error_exit "restore failed"
|
error_exit "restore failed"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function backup {
|
function backup {
|
||||||
echo "backup $LOCAL => $REMOTE"
|
echo "backup $LOCAL => $REMOTE"
|
||||||
if ! aws s3 sync "$LOCAL" "$REMOTE" --delete; then
|
if ! $AWS s3 sync "$LOCAL" "$REMOTE" $S3_SYNC_FLAGS; then
|
||||||
echo "backup failed" 1>&2
|
echo "backup failed" 1>&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -63,7 +69,7 @@ function backup {
|
||||||
|
|
||||||
function final_backup {
|
function final_backup {
|
||||||
echo "backup $LOCAL => $REMOTE"
|
echo "backup $LOCAL => $REMOTE"
|
||||||
while ! aws s3 sync "$LOCAL" "$REMOTE" --delete; do
|
while ! $AWS s3 sync "$LOCAL" "$REMOTE" $S3_SYNC_FLAGS; do
|
||||||
echo "backup failed, will retry" 1>&2
|
echo "backup failed, will retry" 1>&2
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue