Skip to content

Instantly share code, notes, and snippets.

@gbeezus
Created April 22, 2019 16:59
Show Gist options
  • Save gbeezus/4f5458321f50f1ce2c08ba225520a43a to your computer and use it in GitHub Desktop.
Save gbeezus/4f5458321f50f1ce2c08ba225520a43a to your computer and use it in GitHub Desktop.
#!/bin/bash
TERMINUS=/$HOME/vendor/bin/terminus
for i in "$@"
do
case $i in
-s=*|--site=*)
SITE="${i#*=}"
shift # --site=SiteName
;;
-e=*|--env=*)
ENV="${i#*=}"
shift # --env=[dev|test|live|multi-dev]
;;
esac
done
if [ -z "${SITE}" ] && [ -z "${ENV}" ]; then
echo "[-] --site and --env cannot be empty"
exit 1;
fi
month="$(date +'%m')"
day="$(date +'%d')"
year="$(date +'%Y')"
echo "Getting backups"
${TERMINUS} backup:get ${SITE}.${ENV} --element=code --to=${SITE}-$month-$day-$year-code.tar.gz
${TERMINUS} backup:get ${SITE}.${ENV} --element=files --to=${SITE}-$month-$day-$year-files.tar.gz
${TERMINUS} backup:get ${SITE}.${ENV} --element=db --to=${SITE}-$month-$day-$year.sql.gz
echo "Grouping code and files"
cat ${SITE}-$month-$day-$year-code.tar.gz ${SITE}-$month-$day-$year-files.tar.gz > ${SITE}-$month-$day-$year.tar.gz
echo "Upload to drive"
gdrive upload ${SITE}-$month-$day-$year.tar.gz
gdrive upload ${SITE}-$month-$day-$year.sql.gz
echo "Remove backups from local directory"
rm ${SITE}-$month-$day-$year-code.tar.gz
rm ${SITE}-$month-$day-$year-files.tar.gz
rm ${SITE}-$month-$day-$year.tar.gz
rm ${SITE}-$month-$day-$year.sql.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment