Snippet: Copy MySQL Databases Over SSH

I needed to copy a database and the idea of backing it up just to re-import1 seemed like double the work. Here’s a snippet to pipe a mysqldump into a remote database. Keep an eye on the user names and passwords – you’ll need 3 sets; one for the database your copying, one to get into your remote server, and one for the remote, target database.

mysqldump -v -uUSER -pPASSWORD --opt --compress DATABASE_NAME | ssh REMOTE_SERVER_USER@REMOTE_HOSTNAME mysql -uREMOTE-MYSQL-USER -pREMOTE_MYSQL_PASSWORD REMOTE_DATABASE_NAME

1. Backing up is a good thing. Why aren’t you doing it? Here’s a script for that.
mysqldump -h HOSTNAME DATABASE_NAME | gzip -9 > BACKUP_DIR/DATABASE_NAME.sql.gz

How to SFTP into a Virtual Server on Your Joyent Accelerator

I’m finally getting around to setting up my Joyent Accelerator.

As I read through the ‘Getting Started with Joyent Accelerator’ wiki, things were going smoothly.

Updating the nameserver at my registrar was unexpectedly fast and easy, as was signing into webmin, setting up a virtual server, a subversion repo, and a couple users.

Now, which of the half dozen name/pass combos do I use for SFTP?
Answer: The admin of the virtual server.

How to find these credentials:

  1. Select ‘Edit Virtual Server’
  2. Expand ‘Configurable Settings’
  3. Click ‘Show…’

Now SFTP in, and everything should look as expected.