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?
1 Answer
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.
pg_clog,pg_xlog, andglobal? If so, you can just copy it and start PostgreSQL from it. If not, you're boned because a tablespace is pretty meaningless without the shared catalogs, transaction commit logs, etc.