From 72d422a5227ef6f76f412486a395aba9f53bf3f0 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 12 May 2015 09:29:10 -0400 Subject: Map basebackup tablespaces using a tablespace_map file Windows can't reliably restore symbolic links from a tar format, so instead during backup start we create a tablespace_map file, which is used by the restoring postgres to create the correct links in pg_tblspc. The backup protocol also now has an option to request this file to be included in the backup stream, and this is used by pg_basebackup when operating in tar mode. This is done on all platforms, not just Windows. This means that pg_basebackup will not not work in tar mode against 9.4 and older servers, as this protocol option isn't implemented there. Amit Kapila, reviewed by Dilip Kumar, with a little editing from me. --- src/backend/access/transam/xlogfuncs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/backend/access/transam/xlogfuncs.c') diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c index 2179bf719e1..329bb8ca25d 100644 --- a/src/backend/access/transam/xlogfuncs.c +++ b/src/backend/access/transam/xlogfuncs.c @@ -51,6 +51,7 @@ pg_start_backup(PG_FUNCTION_ARGS) bool fast = PG_GETARG_BOOL(1); char *backupidstr; XLogRecPtr startpoint; + DIR *dir; backupidstr = text_to_cstring(backupid); @@ -59,7 +60,16 @@ pg_start_backup(PG_FUNCTION_ARGS) (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("must be superuser or replication role to run a backup"))); - startpoint = do_pg_start_backup(backupidstr, fast, NULL, NULL); + /* Make sure we can open the directory with tablespaces in it */ + dir = AllocateDir("pg_tblspc"); + if (!dir) + ereport(ERROR, + (errmsg("could not open directory \"%s\": %m", "pg_tblspc"))); + + startpoint = do_pg_start_backup(backupidstr, fast, NULL, NULL, + dir, NULL, NULL, false, true); + + FreeDir(dir); PG_RETURN_LSN(startpoint); } -- cgit v1.2.3