Skip to content

Commit 0794d7e

Browse files
author
Andrew Welch
committed
Merge branch 'release/1.2.12'
2 parents 887c940 + cdd82c6 commit 0794d7e

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

Diff for: CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
## 1.2.12 - 2020.10.20
44
### Added
5-
* Added `--set-gtid-purged=OFF` to the `common_mysql.sh` to avoid permissions issues with some managed database dumps
5+
* Added `--set-gtid-purged=OFF` to the `common_mysql.sh` to avoid permissions issues with some database dumps
6+
* Added support for a `LOCAL_AWS_PROFILE` variable, which lets you specify which AWS named profile to connect to S3 with.
7+
* Add in-folder `.gitignore` to ensure that `.env.sh` is ignored
8+
9+
### Fixed
10+
* Fix `TMP_LOG_PATH` for local db backups
611

712
## 1.2.11 - 2020.08.11
813
### Changed

Diff for: README.md

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ This script assumes that you have already [installed awscli](http://docs.aws.ama
8181

8282
It's recommended that you set up a separate user with access to only S3, and set up a private S3 bucket for your backups.
8383

84+
You can set `LOCAL_AWS_PROFILE` to determine which AWS profile to connect with.
85+
8486
See [Mitigating Disaster via Website Backups](https://nystudio107.com/blog/mitigating-disaster-via-website-backups) for a detailed writeup.
8587

8688
### backup_db.sh
@@ -218,6 +220,8 @@ All settings that are prefaced with `LOCAL_` refer to the local environment wher
218220

219221
`LOCAL_BACKUPS_PATH` is the absolute path to the directory where local backups should be stored. For database backups, a sub-directory `LOCAL_DB_NAME/db` will be created inside the `LOCAL_BACKUPS_PATH` directory to store the database backups. Paths should always have a trailing `/`
220222

223+
`LOCAL_AWS_PROFILE` is an [AWS named profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) you can set to determine which profile to connect to S3 with.
224+
221225
##### Using mysql within a local docker container
222226

223227
`LOCAL_MYSQL_CMD` which is normally just `mysql`, is prepended with `docker exec -i CONTAINER_NAME` to execute the command within the container. (Example: `docker exec -i container_mysql_1 mysql`)

Diff for: scripts/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env.sh

Diff for: scripts/backup_db.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ gzip -f "$BACKUP_DB_PATH"
6969
echo "*** Backed up local database to ${BACKUP_DB_PATH}.gz"
7070

7171
# Remove backups older than LOCAL_BACKUPS_MAX_AGE
72-
TMP_LOG_PATH="/tmp/${REMOTE_DB_NAME}-db-backups.log"
72+
TMP_LOG_PATH="/tmp/${LOCAL_DB_NAME}-db-backups.log"
7373
find "${BACKUP_DB_DIR_PATH}" -name "*.sql.gz" -mtime +${GLOBAL_DB_BACKUPS_MAX_AGE} -exec rm -fv "{}" \; &> $TMP_LOG_PATH
7474

7575
# Report on what we did

Diff for: scripts/sync_backups_to_s3.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ echo "Ensuring asset directory exists at '${LOCAL_BACKUPS_PATH}'"
3434
mkdir -p "${LOCAL_BACKUPS_PATH}"
3535

3636
# Sync the local backups to the Amazon S3 bucket
37-
aws s3 sync ${LOCAL_BACKUPS_PATH} s3://${REMOTE_S3_BUCKET}/${REMOTE_S3_PATH}
37+
if [ -z "${LOCAL_AWS_PROFILE}" ] ; then
38+
aws s3 sync "${LOCAL_BACKUPS_PATH}" s3://"${REMOTE_S3_BUCKET}"/"${REMOTE_S3_PATH}"
39+
else
40+
aws --profile="${LOCAL_AWS_PROFILE}" s3 sync "${LOCAL_BACKUPS_PATH}" s3://"${REMOTE_S3_BUCKET}"/"${REMOTE_S3_PATH}"
41+
fi
3842
echo "*** Synced backups to ${REMOTE_S3_BUCKET}"
3943

4044
# Normal exit

0 commit comments

Comments
 (0)