Postgresql – Using a PostgreSQL tablespace from two different servers

exportimportpostgresql

I have a PostgreSQL database living on an external hard disk (RAID0 via Thunderbolt). So far I accessed it from a PostgreSQL server running on my MacBook Pro. As my work on this database is getting more and more intensive the queries are getting more and more complex, too. Therefore I'd like to use my brand spanking new iMac from now on.

My question is: Can I somehow tell the new PostgreSQL server (running on the iMac) to use the data that is already living in the tablespace on the external disk? Or will I have to export & import all the data manually (pg_dump, pg_restore)?

Best Answer

I strongly recommend doing a dump and reload.

Don't put tablespaces on removable media, it doubles your chances of data loss. If either the main database on the main disk or the removable media fails / is lost, your data's gone. A tablespace cannot be read without the database it's from.