You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
850 B

  1. #!/bin/bash
  2. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  3. . "${SCRIPT_DIR}/../settings.sh" || {
  4. echo "no settings" && exit 1
  5. }
  6. CONTAINER=$(docker ps | grep mariadb | awk '{print $1}')
  7. if [[ -z "${CONTAINER}" ]]; then
  8. echo "Unable to find container: db"
  9. exit 1
  10. fi
  11. MYSQL_CMD="docker exec -i ${CONTAINER} mariadb -u root -p123456"
  12. echo -n "Drop and recreate ${LOCAL_DATABASE_NAME} database... "
  13. bash -c "${MYSQL_CMD} -e 'DROP DATABASE \`${LOCAL_DATABASE_NAME}\`'"
  14. bash -c "${MYSQL_CMD} -e 'CREATE DATABASE \`${LOCAL_DATABASE_NAME}\`'"
  15. echo "OK"
  16. echo -n "Importing prod dump data from $SSH_PROD_SERVER ... "
  17. ssh -C ${SSH_PROD_USERNAME}@${SSH_PROD_SERVER} "mariadb-dump --defaults-extra-file=/home/${SSH_PROD_USERNAME}/.my.cnf ${PROD_DATABASE_NAME} | sed '1d'" | pv | bash -c "${MYSQL_CMD} ${LOCAL_DATABASE_NAME}"
  18. echo "OK"