Quickly Backup / dump MySql / Postgres database to another remote server securely
Using UNIX pipe concept one can dump database to another server securely using ssh protocol. All you need remote execution rights for the 'dd' command, over SSH. This allows you to run database dumps across an encrypted channel.
Dump Postgres Database using ssh
Use pg_dump command command:
pg_dump -U USERNAME YOUR-DATABASE-NAME | ssh user@remote.server.com "dd of=/pgsql/$(date +'%d-%m-%y')"
Dump MySQL Database using ssh
Type the following command:
mysqldump -u USERnAME -p'PASSWORD' YOUR-DATABASE-NAME | ssh user@remote.server.com "dd of=/mysql/$(date +'%d-%m-%y')"
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in other helpful articles:
- MySql backup script
- Comparison PostgreSQL vs MySQL database server
- How to MySQL backup and data recovery with mysql-zrm
- Howto: Make consistent MySQL database backups using Solaris ZFS snapshots
- Howto Backup PostgreSQL Databases Server With pg_dump command
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: dd_command, mysqldump_command, mysql_database_backup, pg_dump_command, postgres_database_backup, ssh_protocol, unix_pipe




How do you include the Postgre password in the command line and stop the system from responding that file not found on the remote server?
The MySQL backup command is not secure — anyone can view the password using `ps` on the local machine. It is preferred to use the .my.cnf file, with a [mysqldump] header.