diff --git a/README.md b/README.md index 874eaec..3714870 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ heroku buildpacks:add https://github.com/svikramjeet/db-back-s3 --app heroku config:add AWS_ACCESS_KEY_ID=XXX --app heroku config:add AWS_SECRET_ACCESS_KEY=YYY --app heroku config:add AWS_DEFAULT_REGION=region --app (region example eu-west-1) -heroku config:add S3_BUCKET_PATH=bucket_name --app +heroku config:add AWS_BUCKET=bucket_name --app ``` diff --git a/backup.sh b/backup.sh index 15a2c26..8dc2c5e 100644 --- a/backup.sh +++ b/backup.sh @@ -42,8 +42,8 @@ if [[ -z "$AWS_DEFAULT_REGION" ]]; then echo "Missing AWS_DEFAULT_REGION variable" exit 1 fi -if [[ -z "$S3_BUCKET_PATH" ]]; then - echo "Missing S3_BUCKET_PATH variable" +if [[ -z "$AWS_BUCKET" ]]; then + echo "Missing AWS_BUCKET variable" exit 1 fi if [[ -z "$DATABASE_URL" ]]; then @@ -58,6 +58,6 @@ time pg_dump -b -F c --dbname=$DATABASE_URL | gzip > /tmp/"${DBNAME}_${FILENAME EXPIRATION_DATE=$(date -d "$EXPIRATION days" +"%Y-%m-%dT%H:%M:%SZ") printf "${Green}Move dump to AWS${EC}" -time /app/vendor/bin/aws s3 cp /tmp/"${DBNAME}_${FILENAME}".gz s3://$S3_BUCKET_PATH/$DBNAME/"${DBNAME}_${FILENAME}".gz --expires $EXPIRATION_DATE +time /app/vendor/bin/aws s3 cp /tmp/"${DBNAME}_${FILENAME}".gz s3://$AWS_BUCKET/$DBNAME/"${DBNAME}_${FILENAME}".gz --expires $EXPIRATION_DATE # cleaning after all rm -rf /tmp/"${DBNAME}_${FILENAME}".gz diff --git a/dns-backup.sh b/dns-backup.sh index 5c7a2ee..a017f25 100644 --- a/dns-backup.sh +++ b/dns-backup.sh @@ -18,7 +18,7 @@ dig $1 any +noall +answer | gzip > /tmp/"${FNAME}_${FILENAME}".gz EXPIRATION_DATE=$(date -d "$EXPIRATION days" +"%Y-%m-%dT%H:%M:%SZ") printf "${Green}Move dns-backup to AWS${EC}" -time /app/vendor/bin/aws s3 cp /tmp/"${FNAME}_${FILENAME}".gz s3://$S3_BUCKET_PATH/$FNAME/"${FNAME}_${FILENAME}".gz --expires $EXPIRATION_DATE +time /app/vendor/bin/aws s3 cp /tmp/"${FNAME}_${FILENAME}".gz s3://$AWS_BUCKET/$FNAME/"${FNAME}_${FILENAME}".gz --expires $EXPIRATION_DATE # cleaning after all rm -rf /tmp/"${FNAME}_${FILENAME}".gz diff --git a/env-backup.sh b/env-backup.sh index 3b382e1..a16620d 100644 --- a/env-backup.sh +++ b/env-backup.sh @@ -20,7 +20,7 @@ time printenv | gzip > /tmp/"${FNAME}_${FILENAME}".gz EXPIRATION_DATE=$(date -d "$EXPIRATION days" +"%Y-%m-%dT%H:%M:%SZ") printf "${Green}Move env-backup to AWS${EC}" -time /app/vendor/bin/aws s3 cp /tmp/"${FNAME}_${FILENAME}".gz s3://$S3_BUCKET_PATH/$FNAME/"${FNAME}_${FILENAME}".gz --expires $EXPIRATION_DATE +time /app/vendor/bin/aws s3 cp /tmp/"${FNAME}_${FILENAME}".gz s3://$AWS_BUCKET/$FNAME/"${FNAME}_${FILENAME}".gz --expires $EXPIRATION_DATE # cleaning after all rm -rf /tmp/"${FNAME}_${FILENAME}".gz