Здравствуйте
На просторах интернета был найден bash скрипт для загрузки файлов на Amazon S3. Соотвественно хочу его использовать для автоматизации бэкапов баз данных.
#!/bin/bash
# Use curl command to upload file at S3 bucket.
#upload to S3 bucket
sourceFilePath="/team/test.zip";
#file path at S3
filePathAtS3="test.zip";
#Your S3 bucket name
bucket="*************";
#S3 HTTP Resource URL for your file
resource="/${bucket}/${filePathAtS3}";
#set content type
contentType="application/zip";
#get date as RFC 7231 format
dateValue=`date -R`;
acl="x-amz-acl:public-read"
#String to generate signature
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${acl}\n/${resource}"
# stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}";
#your S3 key. This is specific to S3. This is not your AWS username.
s3Key="**********************";
#your S3 secret. This is specific to S3. This is not your AWS password.
s3Secret="***************************************";
#Generate signature, Amazon re-calculates the signature and compares if it matches the one that was contained in your request. That way the secret access key never needs to be transmitted over the network.
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64`;
#Use curl to make PUT request.
curl -L -X PUT -T "${sourceFilePath}" \
-H "Host: ${bucket}.s3.amazonaws.com" \
-H "Date: ${dateValue}" \
-H "Content-Type: ${contentType}" \
-H "Authorization: AWS ${s3Key}:${signature}" \
https://${bucket}.s3.amazonaws.com/${filePathAtS3}
Результат выполнения скрипта:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>AKIAJP75IY7JM4HXQBKA</AWSAccessKeyId><StringToSign>
Подскажите пожалуйста как исправить данную проблему или подскажите покажите bash скрипт.