Skip to content

Commit

Permalink
Fix create bucket bug
Browse files Browse the repository at this point in the history
  • Loading branch information
suecharo committed Aug 22, 2024
1 parent 8bdfa6a commit a4a8b89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,13 @@ function do_backup() {
local create_bucket=$(echo $S3_CONFIG | jq -r '.createBucket')

if [[ $create_bucket == "true" ]]; then
log "Create bucket: $bucket_name"
aws s3api create-bucket --bucket $bucket_name --endpoint-url $endpoint_url
local exists=$(aws s3api head-bucket --bucket $bucket_name --endpoint-url $endpoint_url 2>&1 || true)
if [[ $exists == "" ]]; then
log "Bucket $bucket_name already exists, so skip create"
else
log "Create bucket: $bucket_name"
aws s3api create-bucket --bucket $bucket_name --endpoint-url $endpoint_url
fi
fi

local count=$(echo $BACKUP_FILES | jq -r ".${OPTION_POLICY} | length")
Expand Down
9 changes: 7 additions & 2 deletions src/public/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,13 @@ function do_backup() {
local create_bucket=$(echo $S3_CONFIG | jq -r '.createBucket')

if [[ $create_bucket == "true" ]]; then
log "Create bucket: $bucket_name"
aws s3api create-bucket --bucket $bucket_name --endpoint-url $endpoint_url
local exists=$(aws s3api head-bucket --bucket $bucket_name --endpoint-url $endpoint_url 2>&1 || true)
if [[ $exists == "" ]]; then
log "Bucket $bucket_name already exists, so skip create"
else
log "Create bucket: $bucket_name"
aws s3api create-bucket --bucket $bucket_name --endpoint-url $endpoint_url
fi
fi

local count=$(echo $BACKUP_FILES | jq -r ".${OPTION_POLICY} | length")
Expand Down

0 comments on commit a4a8b89

Please sign in to comment.