简体   繁体   中英

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.

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.... | mysql -U user -P password -H host.... to pipe mysqldump directly or even use | tee somefile.sql | mysql.... | tee somefile.sql | mysql.... | 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 inte.net, you may use ssh port forwarding/socket forwarding to connect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM