Kaybien
Kaybien

Reputation: 1

How to perform a MySQL Dump to a remote datastore

I am trying to get the databases backed up from a local machine to a datastore. The local machine is a VM within VCenter and I need the DB to go onto one of it's datastores.

I know the command for MySQLDump is:

mysqldump -u (username) -p --all-databases > (backupfilename).sql. 

What do I put in the second section to get it to connect and push the backup to the datastore as a file?

I tried the typical stuff you'd scp and rsync for but I'm not that versed in MariaDB, especially this version we have.

Upvotes: -1

Views: 118

Answers (1)

mickvav
mickvav

Reputation: 320

If you know login credentials and hostname (and whatever extra arguments you need) to connect to remote instance, you may replace > backupfilename.sql with | mysql -U user -P password -H host .... to pipe mysqldump directly or even use | tee somefile.sql | mysql .... to also have a local dump.

Mariadb vs mysql is almost inerchangeable, but dont bet your life on this assumption - check the outcome.

Nb: if remote server is only listening locally and not available via internet, you may use ssh port forwarding/socket forwarding to connect.

Upvotes: 1

Related Questions