How to backup a remote PostgreSQL db and restore it locally?

pg_dump and pg_restore 来备份和恢复数据库中的数据。

原文:  https://ksearch.wordpress.com/2012/09/28/how-to-backup-a-remote-postgresql-db-and-restore-it-locally/

--------------------------------------

This article lists the commands to dump a remote PostgreSQL database in a local file and then restore it on the localhost PostgreSQL server running.

# Please note: The below commands worked for me. It may or may not work for you.

# Please use it at your own risk. # Create a database dump of the the remote DB. pg_dump -h -Fc -o -U remote-postgresql-user remote-db-name > mydatabase.dump # Example: pg_dump -h 10.20.30.40 -Fc -o -U postgres mydatabase > mydatabase.dump # Restore the db dump as a local PostgreSQL database. # Note that I have assumed that you have already installed and configured PostgreSQL

# in your local machine. sudo -u postgres pg_restore -C mydatabase.dump

For a details of the command line options supported by pg_dump and pg_restore, please visit http://www.postgresql.org/docs/9.0/static/app-pgdump.html and http://www.postgresql.org/docs/9.0/static/app-pgrestore.html respectively.

猜你喜欢

转载自www.cnblogs.com/oxspirt/p/9238455.html