如何使用PG_restore备份/移动数据库? [英] How do I use PG_restore to backup/move my DB?
问题描述
我对PQSQL还是很陌生,并且正在慢慢学习-我添加了一个新磁盘,想做两件事:
I am fairly new with PQSQL and am slowly picking things up - I have added a new disk and would like to do two things:
- 将备份恢复到此新磁盘-/ hda2 / pgdata /
- 将数据库从/ hda1 / pgdata移至/ hda2 / pgdata /
推荐答案
Q1。使用pg_restore还原数据库。查看非常清晰的文档。
Q1. Use pg_restore to restore a database. Check out the documentation which is very clear.
要记住的重要一件事,如果要迁移到更高版本的PostgreSQL,请使用更高版本的pg_dump创建备份转储文件。例如,如果要从PostgreSQL版本8.3迁移到版本8.4,请使用版本8.4的pg_dump创建备份转储文件,然后使用pg_restore 8.4在8.4服务器中重新创建数据库。
One important thing to remember, if you want to move to a later version of PostgreSQL use the later version of pg_dump to create a backup dump file. For example if you want to move from PostgreSQL version 8.3 to version 8.4, then create a backup dump file using pg_dump from version 8.4 and then use pg_restore 8.4 to recreate database in the 8.4 server.
http ://www.postgresql.org/docs/8.4/static/app-pgrestore.html
第二季度。备份和还原是一种安全的方法。在恢复之前,可以在新磁盘上创建表空间并将数据库放置在该空间中。
Q2. Backup and restore is a safe way of doing it. Before restoring one can create a tablespace on the new disk and place the database in that space.
CREATE DATABASE mydb TABLESPACE myspace;
http://www.postgresql.org/docs/8.4/interactive/manage-ag-tablespaces.html
这篇关于如何使用PG_restore备份/移动数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!