From fb05f3ce83d225dd0f39f8860ce04082753e9e98 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 22 Feb 2014 13:38:06 -0500 Subject: pg_basebackup: Add support for relocating tablespaces Tablespaces can be relocated in plain backup mode by specifying one or more -T olddir=newdir options. Author: Steeve Lennmark Reviewed-by: Peter Eisentraut --- doc/src/sgml/ref/pg_basebackup.sgml | 46 ++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml index c379df546c6..ea2233123ec 100644 --- a/doc/src/sgml/ref/pg_basebackup.sgml +++ b/doc/src/sgml/ref/pg_basebackup.sgml @@ -202,6 +202,33 @@ PostgreSQL documentation + + + + + + Relocate the tablespace in directory olddir + to newdir during the backup. To be + effective, olddir must exactly match the + path specification of the tablespace as it is currently defined. (But + it is not an error if there is no tablespace + in olddir contained in the backup.) + Both olddir + and newdir must be absolute paths. If a + path happens to contain a = sign, escape it with a + backslash. This option can be specified multiple times for multiple + tablespaces. See examples below. + + + + If a tablespace is relocated in this way, the symbolic links inside + the main data directory are updated to point to the new location. So + the new data directory is ready to be used for a new server instance + with all tablespaces in the updated locations. + + + + @@ -528,9 +555,13 @@ PostgreSQL documentation - The way PostgreSQL manages tablespaces, the path - for all additional tablespaces must be identical whenever a backup is - restored. The main data directory, however, is relocatable to any location. + Tablespaces will in plain format by default be backed up to the same path + they have on the server, unless the + option --tablespace-mapping is used. Without + this option, running a plain format base backup on the same host as the + server will not work if tablespaces are in use, because the backup would + have to be written to the same directory locations as the original + tablespaces. @@ -570,6 +601,15 @@ PostgreSQL documentation (This command will fail if there are multiple tablespaces in the database.) + + + To create a backup of a local database where the tablespace in + /opt/ts is relocated + to ./backup/ts: + +$ pg_basebackup -D backup/data -T /opt/ts=$(pwd)/backup/ts + + -- cgit v1.2.3