Skip to content

Commit 4b9a59c

Browse files
committed
Make s3-sync usable with others than AWS S3
1 parent 59ca89b commit 4b9a59c

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

misc/s3-sync/README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@ Container to sync backups to Amazon S3 and get them from there using s3cmd.
77
- Mount local path `/abs/path/to/backups` to container in `/data`
88
- Sync all files from local path to S3 bucket `foobar-bucket`
99

10-
```
10+
```console
1111
docker run -it -e ACCESS_KEY=foobar -e SECRET_KEY=foobar -e S3_PATH=s3://foobar-bucket \
1212
-v /abs/path/to/backups:/data druidfi/s3-sync sync
1313
```
1414

15-
## Run in cron mode
15+
## Use custom s3cmd configuration
1616

17+
```console
18+
docker run -it -e S3_PATH=s3://foobar-bucket \
19+
-v /abs/path/to/.s3cfg:/root/.s3cfg:ro \
20+
-v /abs/path/to/backups:/data druidfi/s3-sync
1721
```
22+
23+
## Run in cron mode
24+
25+
```console
1826
docker run -it -e ACCESS_KEY=foobar -e SECRET_KEY=foobar -e S3_PATH=s3://foobar-bucket -e CRON_SCHEDULE="*/5 * * * *" \
1927
-v /abs/path/to/backups:/data druidfi/s3-sync
2028
```
@@ -24,9 +32,9 @@ docker run -it -e ACCESS_KEY=foobar -e SECRET_KEY=foobar -e S3_PATH=s3://foobar-
2432
- See the documentation in https://s3tools.org/usage
2533
- Sync specific documentation in https://s3tools.org/s3cmd-sync
2634

27-
## How to give access to S3 bucket
35+
## How to give access to AWS S3 bucket
2836

29-
```
37+
```json
3038
{
3139
"Version": "2008-10-17",
3240
"Statement": [
@@ -50,4 +58,4 @@ docker run -it -e ACCESS_KEY=foobar -e SECRET_KEY=foobar -e S3_PATH=s3://foobar-
5058
}
5159
]
5260
}
53-
```
61+
```

misc/s3-sync/entrypoint.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
# shellcheck disable=SC2086
33

44
DATA_PATH="/data/"
5+
S3CMD_BIN="/usr/bin/s3cmd"
56

6-
: "${ACCESS_KEY:?"ACCESS_KEY env variable is required"}"
7-
: "${SECRET_KEY:?"SECRET_KEY env variable is required"}"
8-
REGION=${REGION:-eu-central-1}
7+
if [ -n "${REGION}" ]; then
8+
$S3CMD_BIN="${$S3CMD_BIN} --region=${REGION}"
9+
fi
10+
11+
if [ -n "${ACCESS_KEY}" ]; then
12+
$S3CMD_BIN="${$S3CMD_BIN} --access_key=${ACCESS_KEY}"
13+
fi
914

10-
S3CMD_BIN="/usr/bin/s3cmd --region=$REGION"
11-
S3CMD_BIN="$S3CMD_BIN --access_key=$ACCESS_KEY"
12-
S3CMD_BIN="$S3CMD_BIN --secret_key=$SECRET_KEY"
15+
if [ -n "${SECRET_KEY}" ]; then
16+
$S3CMD_BIN="${$S3CMD_BIN} --secret_key=${SECRET_KEY}"
17+
fi
1318

1419
if [ "$1" = 'conf' ]; then
1520
echo -e "\n\nsc3cmd:" "$S3CMD_BIN" "\n\n"

0 commit comments

Comments
 (0)