Pantheon Community

Discussion for doc: Terminus Manual - How to run script for two or more sites only

Terminus Manual
i wana to create backups of dev instance for 3-4 sites please guide me how can i create bash script for that which take the backup

We use tags in the dashboard to tag sites and then we use a script like the one below that references those tags to only backup the sites you want. Add in your Pantheon terminus username, ORG ID, and then replace TAGAMEHERE for the tag name you specified in the dashboard.

# Pantheon terminus user (email address)
TERMINUSUSER="user@domain.com"
# The Pantheon organization account
ORG="XXX-XXX-XXXX-XXXX-XXXXXXXXXXXX"
UPDATEENV="dev"

RED='\033[0;31m'
NC='\033[0m'

# connect to terminus
terminus auth:login --email $TERMINUSUSER

# get the sites
SITENAMES=`terminus org:site:list --field=id --format=list --tag=TAGNAMEHERE $ORG`

backupSite () {
  NAME="$(terminus site:info $thissite --field Name)"
  
  printf "${RED}========== Starting $NAME ==========${NC}\n"
  
  terminus backup:create $thissite.$UPDATEENV
  
  printf "${RED}========== Finished $NAME ==========${NC}\n"
  
}

# run through the sites
for thissite in $SITENAMES; do backupSite "$thissite" & done