Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The below table lists all of the Environment Variables that are configurable for
| AWS_ACCESS_KEY_ID | **(Required)** AWS IAM Access Key ID. |
| AWS_SECRET_ACCESS_KEY | **(Required)** AWS IAM Secret Access Key. Should have very limited IAM permissions (see below for example) and should be configured using a Secret in Kubernetes. |
| AWS_DEFAULT_REGION | **(Required)** Region of the S3 Bucket (e.g. eu-west-2). |
| AWS_BUCKET_NAME | **(Required)** The name of the S3 bucket. |
| AWS_BUCKET_URI | **(Required)** The name of the S3 bucket. |
| AWS_BUCKET_BACKUP_PATH | **(Required)** Path the backup file should be saved to in S3. E.g. `/database/myblog/backups`. **Do not put a trailing / or specify the filename.** |
| TARGET_DATABASE_HOST | **(Required)** Hostname or IP address of the MySQL Host. |
| TARGET_DATABASE_PORT | **(Optional)** Port MySQL is listening on (Default: 3306). |
Expand Down Expand Up @@ -122,8 +122,8 @@ spec:
key: aws_secret_access_key
- name: AWS_DEFAULT_REGION
value: "<Your S3 Bucket Region>"
- name: AWS_BUCKET_NAME
value: "<Your S3 Bucket Name>"
- name: AWS_BUCKET_URI
value: "<Your S3 Bucket URI>"
- name: AWS_BUCKET_BACKUP_PATH
value: "<Your S3 Bucket Backup Path>"
- name: TARGET_DATABASE_HOST
Expand Down
5 changes: 4 additions & 1 deletion resources/perform-backup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#/bin/sh

if [[ "${DEBUG}" != "" ]] ; then
set -x
fi

# Set the has_failed variable to false. This will change if any of the subsequent database backups/uploads fail.
has_failed=false
Expand All @@ -17,7 +20,7 @@ do
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
# 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 2>&1)
if awsoutput=$(aws s3 ${S3_OPTIONS} cp /tmp/$CURRENT_DATABASE.sql $AWS_BUCKET_URI$AWS_BUCKET_BACKUP_PATH/$backup_name 2>&1)
then
echo -e "Database backup successfully uploaded for $CURRENT_DATABASE at $(date +'%d-%m-%Y %H:%M:%S')."
else
Expand Down