From 202888244e6086f96ffe9b31cc562e64e955e4e4 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Mon, 22 Jul 2024 18:09:38 -0300 Subject: [PATCH] Update perform-backup.sh --- resources/perform-backup.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/resources/perform-backup.sh b/resources/perform-backup.sh index fdcef29..9b231e4 100644 --- a/resources/perform-backup.sh +++ b/resources/perform-backup.sh @@ -9,17 +9,15 @@ backup_name="" # Loop through all the defined databases, seperating by a , for CURRENT_DATABASE in ${TARGET_DATABASE_NAMES//,/ } do + # Perform the database backup. Put the output to a variable. If successful upload the backup to S3, if unsuccessful print an entry to the console and the log, and set has_failed to true. if sqloutput=$(mysqldump -u $TARGET_DATABASE_USER -h $TARGET_DATABASE_HOST -p$TARGET_DATABASE_PASSWORD -P $TARGET_DATABASE_PORT $CURRENT_DATABASE 2>&1 > /tmp/$CURRENT_DATABASE.sql) then echo -e "Database backup successfully completed for $CURRENT_DATABASE at $(date +'%d-%m-%Y %H:%M:%S')." backup_name=$CURRENT_DATABASE_$(date +"%Y-%m-%d_%H-%M-%S").sql - - echo -e "aws s3 cp /tmp/$CURRENT_DATABASE.sql s3://$AWS_BUCKET_NAME$AWS_BUCKET_BACKUP_PATH/$backup_name --endpoint-url=$AWS_ENDPOINT_URL" - - # Perform the upload to R2. Put the output to a variable. If successful, print an entry to the console and the log. If unsuccessful, set has_failed to true and print an entry to the console and the log - if awsoutput=$(aws s3 cp "/tmp/$CURRENT_DATABASE.sql" s3://$AWS_BUCKET_NAME$AWS_BUCKET_BACKUP_PATH/$backup_name --endpoint-url=$AWS_ENDPOINT_URL 2>&1) + # Perform the upload to S3. Put the output to a variable. If successful, print an entry to the console and the log. If unsuccessful, set has_failed to true and print an entry to the console and the log + if awsoutput=$(aws s3 cp /tmp/$CURRENT_DATABASE.sql $AWS_BUCKET_URI$AWS_BUCKET_BACKUP_PATH/$backup_name --endpoint-url=$AWS_ENDPOINT_URL 2>&1) then echo -e "Database backup successfully uploaded for $CURRENT_DATABASE at $(date +'%d-%m-%Y %H:%M:%S')." else