I would like to simplify SSH Tunneling to do a MyS

2019-08-05 05:09发布

问题:

Server setup (fake IPs)

  • utility - 1.1.1.1 - SSH access on public IP
  • database2 - 1.1.1.2 - SSH access on private IP from utility

On a semi-regular basis I need to do a mysqldump on database2 and pull that down to my local machine so I can debug our app with real data. My current process is as follows:

  • ssh into utility
  • ssh into database2
  • execute mysqldump command
  • exit from database2
  • scp dump file down to utility
  • exit utility
  • scp dump file down to local machine

Needless to say this is not optimal. Is there a quicker method, possibly via tunneling, that I could use given my setup?

回答1:

you can

  1. make dump by cron on database2
  2. make port forward on utility and connect at once to database2

summary: you will get dump by one scp command.

UPD:

if you can't port forward or cron, you can add access to database from utility and make mysqldump from him.