简体   繁体   中英

How do I recover / move PostgreSQL database schema and databases between systems on Windows?

I'm using PostgreSQL 9.2 database on Windows XP. That database is installed under OS partition. Unfortunately my hard drive is broken but it can be use as second drive not bootable drive. So I have my PostgreSQL 9.2 folder and where can I retrieve my database schema from?

Unless you did something extravagant in you last installation, all the files you need should be in the data directory. This includes the schema, configuration and you user created databases. If you ran an installer (rather than manually set it up), If you used an installer of some sort, it likely puts in the following path (for Windows):

C:\Program Files\PostgreSQL\<someversion>\data 

or, if you install 32-bit PostgreSQL on 64-bit windows, it may be:

C:\Program Files (x86)\PostgreSQL\<someversion>\data
  1. Just install PostgreSQL the same way and to the same path
  2. Stop the database process.
  3. Rename the "new" data directory to data_BACKUP (so you can recover your install if necessary).
  4. Copy over the entire "data" directory from the old disk to the same location on the new disk.
  5. Restart the database process and you'll be all set.

Postgres maintains very good documentation on this: http://www.postgresql.org/docs/9.2/static/storage.html

But, your data could be anywhere depending on how you configured your database. By default, it is located in windows under the installation directory in 'data'. Without more specific information about your installation, though, we don't know where your data is, either.

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