Download logs from Pantheon

Use Terminus to download the logs with a script that you install on your local development environment. The original source of the script is from Pantheon.

1. Install Terminus.

2. Create "site-logs" in the root of the project as a sister folder to "web".

3. Place DONT_REMOVE.txt in that directory.

4. Add the following to .gitignore:
site-logs/*.gz
site-logs/*.log
5. Commit to the repo.

6. Place the following script in a folder on the path. I use ~/LocalDevelopment/shell_scripts.

#!/bin/sh

# This is for Pantheon sites.

# The Site UUID comes from the Dashboard URL, eg 12345678-1234-1234-abcd-0123456789ab

if [ -z "$1" ]
  then
  echo "Please provide a Site UUID."
  exit
fi

if [ -z "$2" ]
  then
  echo "Please provide the environment (dev, test, live)."
  exit
fi

SITE_UUID=$1
ENV=$2

#438108bb-37d2-42cc-8132-2e8e3a0551bc
#ENV=dev

echo "For Site {$1}.{$2}."

for app_server in `dig +short appserver.$ENV.$SITE_UUID.drush.in`;
do
  rsync -rlvz --size-only --ipv4 --progress -e 'ssh -p 2222' $ENV.$SITE_UUID@appserver.$ENV.$SITE_UUID.drush.in:logs/* app_server_$app_server
done

# Include MySQL logs
db_server=`dig dbserver.$ENV.$SITE_UUID.drush.in +short`
rsync -rlvz --size-only --ipv4 --progress -e 'ssh -p 2222' $ENV.$SITE_UUID@dbserver.$ENV.$SITE_UUID.drush.in:logs db_server_$db_server

7. Set the execution bit with:
chmod +x collect-logs.sh

8. Make sure the script directory is in the PATH.

9. Obtain the Site UUID from the bolded part of URL in the Pantheon dashboard:

https://dashboard.pantheon.io/sites/438108bb-37d2-42cc-8132-2e8e3a0551bc

10. Change to the project directory and run the script. The command below gets the logs for the dev environment.

cd ~/Sites/performantlabs

collect-shell.sh 438108bb-37d2-42cc-8132-2e8e3a0551bc dev