user2089477
user2089477

Reputation: 55

Restoring Postgres database without pg dump?

I have a postgre database DATA1 in table space location D:\tbl_DATA1. We use OS backup restore tool copy the the D:\tbl_DATA1 to a target machine C:\tbl_DATA1. Is it possible for recreate the database from this folder in the second mahcine?

Upvotes: 1

Views: 2025

Answers (1)

Vao Tsun
Vao Tsun

Reputation: 51639

https://www.postgresql.org/docs/current/static/backup-file.html

An alternative backup strategy is to directly copy the files that PostgreSQL uses to store the data in the database

and later two restrictions mentionned

  • The database server must be shut down in order to get a usable backup.
  • You should resotore the whole PGDATA direcotory, not the certain individual tables or databases from their respective files or directories.

So yes - it is a common practice to shutdown the PostgreSQL, copy PGDATA directory to other machine and start Postgres in order to get the cluser copy. But it is done cluster level - not tablespace as you mention or database - the whole data_directory should be copied.

So no - copying the tablespace directory and trying to hack the db to add a tablespace will fail.

Upvotes: 3

Related Questions