Skip to content

Commit e1fb9cb

Browse files
author
CaffeinatedTech
committed
Update S3 API in backup script.
1 parent 6098ab1 commit e1fb9cb

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

backup.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,18 @@ echo "Archive size: ${ARCHIVE_SIZE}"
124124
# --- Upload ---
125125
echo "Uploading ${ARCHIVE_NAME} to S3 bucket '${S3_BUCKET}'..."
126126
# Use aws-cli to upload the archive to the S3-compatible storage.
127-
aws s3 cp \
128-
"${ARCHIVE_PATH}" \
129-
"s3://${S3_BUCKET}/${ARCHIVE_NAME}" \
130-
--endpoint-url "${S3_ENDPOINT}"
127+
# Configure AWS CLI to handle Content-Length properly
128+
export AWS_ACCESS_KEY_ID="${S3_ACCESS_KEY}"
129+
export AWS_SECRET_ACCESS_KEY="${S3_SECRET_KEY}"
130+
export AWS_DEFAULT_REGION="${S3_REGION:-us-east-1}"
131+
132+
# Use s3api put-object instead of s3 cp to have more control over headers
133+
aws s3api put-object \
134+
--bucket "${S3_BUCKET}" \
135+
--key "${ARCHIVE_NAME}" \
136+
--body "${ARCHIVE_PATH}" \
137+
--endpoint-url "${S3_ENDPOINT}" \
138+
--content-type "application/gzip"
131139

132140
echo "Backup upload complete: ${ARCHIVE_NAME} (${ARCHIVE_SIZE})"
133141

0 commit comments

Comments
 (0)