Created
April 18, 2019 14:39
-
-
Save purdy/fcc72b69544b4a865a1f2350915b1383 to your computer and use it in GitHub Desktop.
Pantheon build script for master-lite environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is a daily script to build an updated master-lite database for our various pubs. | |
for site in site1 site2 site3 | |
do | |
echo "Building master-lite for $site" | |
# First, make sure the master-lite env is woke. | |
echo "Making sure master-lite environment is woke - $site." | |
terminus env:wake $site.master-lite | |
echo "Done (woke - $site)" | |
# Make sure master-lite branch is caught up with master. | |
echo "Merging any master commits to the master-lite branch - $site" | |
terminus multidev:merge-from-dev $site.master-lite --yes | |
echo "Done (merging master commits - $site)" | |
# We need to sync content from live to the master-lite environment. | |
echo "Now for the long part - cloning content from prod to master-lite - $site" | |
terminus env:clone-content $site.live master-lite --cc --no-interaction --yes | |
echo "Done (cloning content - $site)" | |
# Now we need to trim the large tables, except for site3 | |
if [ "$site" != "site3" ] | |
then | |
MYSQL_CMD="$(terminus connection:info $site.master-lite --field mysql_command)" | |
echo "Truncating large tables - $site..." | |
${MYSQL_CMD} < ./$site-lite.sql | |
echo "Done (truncating large tables - $site)" | |
else | |
echo "Skipping large table truncation for site3 since it doesn't have any" | |
fi | |
# The Quicksilver sanitize hook probably timed out, so let's make sure we explicitly sanitize our db. | |
# Should go faster since we truncated the large tables. | |
echo "Calling sql-sanitize - $site" | |
terminus drush $site.master-lite -- sql-sanitize --sanitize-password="password" --yes | |
echo "Done (sql-sanitize - $site)" | |
# Finally, create a backup... | |
echo "Finally, making a database backup - $site" | |
terminus backup:create $site.master-lite --element=db | |
echo "Done (db backup - $site)" | |
echo "Done building master-lite for $site" | |
done | |
echo "All done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment