Created
August 28, 2020 08:46
-
-
Save mikedamoiseau/8045b24aa26a6e7379380471a8e9d367 to your computer and use it in GitHub Desktop.
Drupal - Backup DB using Drush
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 | |
# staging or production | |
DB_ENV="staging" | |
##### DO NOT EDIT FROM HERE ##### | |
# Find the container | |
CONTAINER="$(docker ps | grep c-${DB_ENV} | awk '{print $1}')" | |
# Timestamp (used to build dump filename) | |
DATE=$(date +"%Y%m%d%H%M%S") | |
# Dump filename | |
DUMP_FILENAME="sigel_${DB_ENV}_${DATE}.sql" | |
# Export the DB | |
docker exec -w /var/www/html ${CONTAINER} drush sql-dump --gzip --structure-tables-key=common --result-file=/tmp/${DUMP_FILENAME} | |
# Move the dump to the backups folder | |
mv /tmp/${DUMP_FILENAME}.gz ~/backups/${DB_ENV}/${DUMP_FILENAME}.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment