有关此问题的概述。
db-backup.sh
#!/bin/bash
# Dump the db database from the RDS readreplica and move it to S3.
# Dump the db database from the RDS readreplica and move it to S3.
# S3 Bucket has policy access to only allow db-backup IAM User PutObject
# mysqlbackup is used to backup files
bucketName="backups"
today=$(date +%d)
endPoint2="database-endpoint"
#All databases, routines, procedures, etc
mysqldump db --routines --triggers | gzip > /root/db-$(date +%Y%m%d).sql.gz
aws --profile db-backup s3 cp /root/db-$(date +%Y%m%d).sql.gz s3://dbaccount-backups/db-database-backups/
aws --profile db-backup s3api put-object-tagging --bucket $bucketName --key db-database-backups/db-$(date +%Y%m%d).sql.gz --tagging 'TagSet=[{Key=retention,Value=60}]'
rm /root/db-$(date +%Y%m%d).sql.gz
#Schema backups
mysqldump db --no-data | gzip > /root/db-schema-$(date +%Y%m%d).sql.gz
aws --profile db-backup s3 mv /root/db-schema-$(date +%Y%m%d).sql.gz s3://dbaccount-backups/db-schema-backups/
aws --profile db-backup s3api put-object-tagging --bucket $bucketName --key db-schema-backups/db-schema-$(date +%Y%m%d).sql.gz --tagging 'TagSet=[{Key=retention,Value=14}]'