Allow configuration of the endpoint url

This commit is contained in:
Mauricio H Nagaoka 2019-08-06 16:31:40 -03:00
parent 1288239de3
commit 9cb9e30ad7
2 changed files with 18 additions and 3 deletions

View File

@ -49,6 +49,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

12
watch
View File

@ -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" --delete; 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" --delete; do
echo "backup failed, will retry" 1>&2 echo "backup failed, will retry" 1>&2
sleep 1 sleep 1
done done