Skip to content

Instantly share code, notes, and snippets.

@iamEAP
Last active November 3, 2015 10:21
Show Gist options
  • Save iamEAP/9477863 to your computer and use it in GitHub Desktop.
Save iamEAP/9477863 to your computer and use it in GitHub Desktop.
Keep Pantheon test environment up-to-date and squeeky clean
#!/bin/bash
PSITE='your-site-name'
PUUID='aaaaaaaa-1111-bbbb-2222-cccccccccccc'
PEMAIL='[email protected]'
PPASS='your-password-here--i-know'
# Authenticate with Terminus
drush pauth $PEMAIL --password=$PPASS
# Update Pantheon aliases.
drush paliases
# Clone from the live environment to the test environment.
drush psite-clone $PUUID live test -y
# Sleep for an hour; the above command returns long before the clone completes.
# I wish this could be more deterministic, but alas...
sleep 3600
# Once cloned, clean out cache and other ephemeral data that's not needed.
`drush @pantheon.$PSITE.test sql-connect` -e "SELECT CONCAT('TRUNCATE TABLE ', TABLE_NAME, ';') FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'pantheon' AND TABLE_NAME LIKE 'cache%' OR TABLE_NAME IN ('watchdog', 'accesslog', 'queue', 'sessions');" | sed 1d | `drush @pantheon.$PSITE.test sql-connect`
# Use simpleSAMLphp? Drop tables. They'll restore themselves when needed.
`drush @pantheon.$PSITE.test sql-connect` -e "SELECT CONCAT('DROP TABLE ', TABLE_NAME, ';') FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'pantheon' AND TABLE_NAME LIKE 'simpleSAMLphp_%';" | sed 1d | `drush @pantheon.$PSITE.test sql-connect`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment