8

I have a server setup as follows:

  • webserver (gateway machine, accessible from the Internet via SSH)
  • dbserver (database server, not accessible from the web)

My goal is to use mysqldump to pull a backup from dbserver to my laptop via the web. Up to this point, the question is a duplicate of this question, except that webserver does not have mysqldump installed, and I don't have the rights to install it. So I'm trying to use mysqldump on my laptop to pull from a server behind a gateway that I don't have SSH rights to.

Following the discussions here and here, I'm trying to do something like this to set up the tunnel:

ssh -f -L 3306:dbserver:3306 user@webserver -N

followed by:

mysqldump -P 3306 -h localhost -u dbuser -p db

but I run into the same trouble this person did, and am not quite sure what's going on with the tunneling or how to fix it (and adding an entry to my laptop's hosts file doesn't seem to fix it like it did for him).

Community
  • 1
  • 1
SigmaX
  • 463
  • 6
  • 13

1 Answers1

0

Dump databases daily to the gateway machine then fetch from there

#!/bin/sh
# Backup the mysql Databases
 for database in $(mysql -u b4ckup -pd1psh1t --host server.database.net -e "show databases" | awk '{print $1}' | grep -v Database)
do
        mysqldump -u user -p password --lock-tables=false --host server.database.net $database > /storage/backups/`date +\%Y-\%m-\%d`-`date +\%A`/server/$database.sql
done 
Paperghost
  • 96
  • 9
  • 1
    mysqldump is not installed on the gateway machine. – SigmaX Aug 30 '12 at 11:09
  • you are calling the dump on the mysql server box – Paperghost Aug 30 '12 at 11:52
  • Got it. +1, but I wasn't clear enough: I do not have SSH access to the dbserver machine _at all_, so I have no way to invoke mysqldump directly on the dbserver. Thus my attempt to use my local mysqldump instance, but I have to pass through the gateway to do so. This would all be so simple if my university still allowed VPN access to non-faculty >. – SigmaX Aug 30 '12 at 20:22