Skip to content

Commit 53dd744

Browse files
authored
Merge pull request #1038 from seth-reeser/develop-catapult
RedHat: Extend website idle option to exclude database backup.
2 parents 4444c88 + 58f1eb1 commit 53dd744

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

VERSION.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
version: 4.7.1
2+
version: 4.8.0
33
major:
44
description: "Catapult uses Semantic Versioning. During a MAJOR increment, incompatable API changes are made which require a manual upgrade path. Please follow these directions:"
55
notice: "NEW MAJOR VERSION OF CATAPULT AVAILABLE"

provisioners/redhat/modules/mysql_database_backup.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ branch=$(catapult environments.$1.branch)
44
dbconf="/catapult/provisioners/redhat/installers/temp/${1}.cnf"
55
domain=$(catapult websites.apache.$5.domain)
66
domain_valid_db_name=$(catapult websites.apache.$5.domain | tr "." "_" | tr "-" "_")
7+
idle=$(catapult websites.apache.$5.idle)
78
software=$(catapult websites.apache.$5.software)
89
software_dbprefix=$(catapult websites.apache.$5.software_dbprefix)
910
software_workflow=$(catapult websites.apache.$5.software_workflow)
@@ -18,12 +19,16 @@ if ([ ! -z "${software}" ]); then
1819

1920
if ([ "${1}" = "production" ] && [ "${software_workflow}" = "downstream" ] && [ "${software_db}" != "" ] && [ "${software_db_tables}" != "0" ]) || ([ "${1}" = "test" ] && [ "${software_workflow}" = "upstream" ] && [ "${software_db}" != "" ] && [ "${software_db_tables}" != "0" ]); then
2021
# dump the database as long as it hasn't already been dumped for the day
21-
if ! [ -f /var/www/repositories/apache/${domain}/_sql/$(date +"%Y%m%d").sql.lock ]; then
22+
if [ "${idle}" = "True" ]; then
23+
echo -e "\t* skipping database backup, website is set to idle"
24+
elif [ -f /var/www/repositories/apache/${domain}/_sql/$(date +"%Y%m%d").sql.lock ]; then
25+
echo -e "\t* a database backup was already performed today"
26+
else
2227
echo -e "\t* performing a database backup"
2328
# create the _sql directory if it does not exist
2429
mkdir --parents "/var/www/repositories/apache/${domain}/_sql"
2530
# dump the database
26-
mysqldump --defaults-extra-file=$dbconf --lock-tables=false --single-transaction --quick ${1}_${domain_valid_db_name} > /var/www/repositories/apache/${domain}/_sql/$(date +"%Y%m%d").sql
31+
mysqldump --defaults-extra-file=$dbconf --lock-tables=false --max_allowed_packet=512M --single-transaction --quick ${1}_${domain_valid_db_name} > /var/www/repositories/apache/${domain}/_sql/$(date +"%Y%m%d").sql
2732
# write out a sql lock file for use in controlling what is restored in other environments
2833
touch "/var/www/repositories/apache/${domain}/_sql/$(date +"%Y%m%d").sql.lock"
2934
# ensure no more than 250mb or at least the one, newest, YYYYMMDD.sql file exists
@@ -48,8 +53,6 @@ if ([ ! -z "${software}" ]); then
4853
&& git add --all "_sql" \
4954
&& git commit --message="Catapult auto-commit ${1}:${software_workflow}:software_database" \
5055
&& sudo ssh-agent bash -c "ssh-add /catapult/secrets/id_rsa; git fetch && git pull origin ${branch} && git push origin ${branch}"
51-
else
52-
echo -e "\t* a database backup was already performed today"
5356
fi
5457
fi
5558

provisioners/redhat/modules/mysql_database_table_retain.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if ([ ! -z "${software}" ]); then
2727
mkdir --parents "/var/www/repositories/apache/${domain}/_sql"
2828
# dump the database tables that are specified
2929
# note if there is an invalid table, there will be an error of: mysqldump: Couldn't find table: "test"
30-
mysqldump --defaults-extra-file=$dbconf --lock-tables=false --single-transaction --quick ${1}_${domain_valid_db_name} ${software_dbtable_retain[*]} > /var/www/repositories/apache/${domain}/_sql/$(date +"%Y%m%d")_software_dbtable_retain.sql
30+
mysqldump --defaults-extra-file=$dbconf --lock-tables=false --max_allowed_packet=512M --single-transaction --quick ${1}_${domain_valid_db_name} ${software_dbtable_retain[*]} > /var/www/repositories/apache/${domain}/_sql/$(date +"%Y%m%d")_software_dbtable_retain.sql
3131
# write out a sql lock file for use in controlling what is restored in other environments
3232
touch "/var/www/repositories/apache/${domain}/_sql/$(date +"%Y%m%d")_software_dbtable_retain.sql.lock"
3333
# ensure no more than 50mb or at least the one, newest, YYYYMMDD_software_dbtable_retain.sql file exists

0 commit comments

Comments
 (0)