Created
April 22, 2019 16:59
-
-
Save gbeezus/4f5458321f50f1ce2c08ba225520a43a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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