diff --git a/HISTORY b/HISTORY index 32548f5c..225756d2 100644 --- a/HISTORY +++ b/HISTORY @@ -5,6 +5,8 @@ repmgr: "primary unregister --force" will unregister an active primary with no registered standby nodes (Ian) repmgr: add option --verify-backup to "standby clone" (Ian) + repmgr: "standby clone" honours --waldir option if set in + "pg_basebackup_options" (Ian) repmgr: add option --db-connection to "node check" (Ian) repmgr: report database connection error if the --optformat option was provided to "node check" (Ian) diff --git a/doc/appendix-faq.xml b/doc/appendix-faq.xml index 3db567d4..4dc2a502 100644 --- a/doc/appendix-faq.xml +++ b/doc/appendix-faq.xml @@ -350,6 +350,9 @@ and earlier) with the absolute path to the WAL directory in pg_basebackup_options. For more details see . + + In &repmgr; 5.2 and later, this setting will also be honoured when cloning from Barman. + diff --git a/doc/appendix-release-notes.xml b/doc/appendix-release-notes.xml index 39a8abbb..03fb890d 100644 --- a/doc/appendix-release-notes.xml +++ b/doc/appendix-release-notes.xml @@ -82,6 +82,18 @@ + + + repmgr standby clone: + when cloning from Barman, setting + (PostgreSQL 9.6 and earlier: ) in + will cause &repmgr; to create + a WAL directory outside of the main data directory and symlink + it from there, in the same way as would happen when cloning + using pg_basebackup. + + + repmgr standby follow: diff --git a/doc/cloning-standbys.xml b/doc/cloning-standbys.xml index b96e4901..53fc283c 100644 --- a/doc/cloning-standbys.xml +++ b/doc/cloning-standbys.xml @@ -148,6 +148,15 @@ description = "Main cluster" section in man 5 ssh_config for more details. + + If you wish to place WAL files in a location outside the main + PostgreSQL data directory, set + (PostgreSQL 9.6 and earlier: ) in + to the target directory + (must be an absolute filepath). &repmgr; will create and + symlink to this directory in exactly the same way + pg_basebackup would. + It's now possible to clone a standby from Barman, e.g.: @@ -440,6 +449,13 @@ description = "Main cluster" WAL directory. Any WALs generated during the cloning process will be copied here, and a symlink will automatically be created from the main data directory. + + + The --waldir (--xlogdir) option, + if present in pg_basebackup_options, will be honoured by &repmgr; + when cloning from Barman (&repmgr; 5.2 and later). + + See the PostgreSQL pg_basebackup documentation for more details of available options. diff --git a/doc/repmgr-standby-clone.xml b/doc/repmgr-standby-clone.xml index 06e40384..0ca49ad1 100644 --- a/doc/repmgr-standby-clone.xml +++ b/doc/repmgr-standby-clone.xml @@ -191,6 +191,25 @@ + + + Placing WAL files into a different directory + + + To ensure that WAL files are placed in a directory outside of the main data + directory (e.g. to keep them on a separate disk for performance reasons), + specify the location with + (PostgreSQL 9.6 and earlier: ) in + the repmgr.conf parameter , + e.g.: + +pg_basebackup_options='--waldir=/path/to/wal-directory' + This setting will also be honored by &repmgr; when cloning from Barman + (&repmgr; 5.2 and later). + + + + diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index 19bef47e..62a9e687 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -6941,9 +6941,20 @@ run_file_backup(t_node_info *local_node_record) /* For the foreseeable future, no other modes are supported */ Assert(mode == barman); - if (mode == barman) { + t_basebackup_options backup_options = T_BASEBACKUP_OPTIONS_INITIALIZER; + + Assert(source_server_version_num != UNKNOWN_SERVER_VERSION_NUM); + + /* + * Parse the pg_basebackup_options provided in repmgr.conf - we need to + * check if --waldir/--xlogdir was provided. + */ + parse_pg_basebackup_options(config_file_options.pg_basebackup_options, + &backup_options, + source_server_version_num, + NULL); /* * Locate Barman's base backups directory */ @@ -7203,11 +7214,31 @@ run_file_backup(t_node_info *local_node_record) if (vers[i] < 0 && source_server_version_num >= abs(vers[i])) continue; + maxlen_snprintf(filename, "%s/%s", local_data_directory, dirs[i]); + /* * If --waldir/--xlogdir specified in "pg_basebackup_options", * create a symlink rather than make a directory. */ - maxlen_snprintf(filename, "%s/%s", local_data_directory, dirs[i]); + if (strcmp(dirs[i], "pg_wal") == 0 || strcmp(dirs[i], "pg_xlog") == 0) + { + if (backup_options.waldir[0] != '\0') + { + if (create_pg_dir(backup_options.waldir, false) == false) + { + /* create_pg_dir() will log any errors */ + exit(ERR_BAD_CONFIG); + } + + if (symlink(backup_options.waldir, filename) != 0) + { + log_error(_("could not create symbolic link \"%s\""), filename); + exit(ERR_BAD_CONFIG); + } + continue; + } + } + if (mkdir(filename, S_IRWXU) != 0 && errno != EEXIST) { log_error(_("unable to create the %s directory"), dirs[i]); diff --git a/repmgr.conf.sample b/repmgr.conf.sample index 07d0fae1..80bb8635 100644 --- a/repmgr.conf.sample +++ b/repmgr.conf.sample @@ -181,6 +181,8 @@ #pg_ctl_options='' # Options to append to "pg_ctl" #pg_basebackup_options='' # Options to append to "pg_basebackup" + # (Note: when cloning from Barman, repmgr will honour any + # --waldir/--xlogdir setting present in "pg_basebackup_options" #rsync_options='' # Options to append to "rsync" ssh_options='-q -o ConnectTimeout=10' # Options to append to "ssh"