Skip to content

Instantly share code, notes, and snippets.

@altherlex
Created July 6, 2022 16:53
Show Gist options
  • Save altherlex/84691ed157364c4c95887db52c47319c to your computer and use it in GitHub Desktop.
Save altherlex/84691ed157364c4c95887db52c47319c to your computer and use it in GitHub Desktop.
Dump mysql via tunnel
# Create tunnel gateway
$ ssh -L 3306:staging-bastion:3306 tunnel@staging-bastion
# Check the port
$ nc -z localhost 3306
# Dump via tunnel
$ mysqldump -P 3306 -ualther -p '9E@EeM#C)(Ip$n%9Cy6EIr}QyD!ZbFd' staging_myhi > staging_myhi.sql -h staging-myhi.csqfg2d4yaps.ca-central-1.rds.amazonaws.co
# - with gzip
$ mysqldump -P 3306 -ualther -p '9E@EeM#C)(Ip$n%9Cy6EIr}QyD!ZbFd' -h staging-myhi.csqfg2d4yaps.ca-central-1.rds.amazonaws.com staging_myhi | gzip > stage-myhi.sql.gz
# Execute command via tunnel
$ ssh tunnel@staging-bastion mysqldump -u alther -p=9E@EeM#C)(Ip$n%9Cy6EIr}QyD!ZbFd staging_myhi | gzip > staging_myhi.sql.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment