mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Ensure pg_replslot directory is cleaned up after "standby clone" with rsync
This ensures the directory is in the same state as it would be after cloning the standby with pg_basebackup, i.e. empty.
This commit is contained in:
33
repmgr.c
33
repmgr.c
@@ -1761,13 +1761,20 @@ stop_backup:
|
||||
exit(retval);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Remove existing WAL from the target directory, since
|
||||
* rsync's --exclude option doesn't do it.
|
||||
* Clean up any $PGDATA subdirectories which may contain
|
||||
* files which won't be removed by rsync and which could
|
||||
* be stale or are otherwise not required
|
||||
*/
|
||||
if (runtime_options.force)
|
||||
if (runtime_options.rsync_only && runtime_options.force)
|
||||
{
|
||||
char script[MAXLEN];
|
||||
|
||||
/*
|
||||
* Remove any existing WAL from the target directory, since
|
||||
* rsync's --exclude option doesn't do it.
|
||||
*/
|
||||
maxlen_snprintf(script, "rm -rf %s/pg_xlog/*",
|
||||
local_data_directory);
|
||||
r = system(script);
|
||||
@@ -1777,6 +1784,26 @@ stop_backup:
|
||||
local_data_directory);
|
||||
exit(ERR_BAD_RSYNC);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove any replication slot directories; this matches the
|
||||
* behaviour a base backup, which would result in an empty
|
||||
* pg_replslot directory.
|
||||
*
|
||||
* NOTE: watch out for any changes in the replication
|
||||
* slot directory name (as of 9.4: "pg_replslot") and
|
||||
* functionality of replication slots
|
||||
*/
|
||||
|
||||
maxlen_snprintf(script, "rm -rf %s/pg_replslot/*",
|
||||
local_data_directory);
|
||||
r = system(script);
|
||||
if (r != 0)
|
||||
{
|
||||
log_err(_("unable to empty replication slot directory %s/pg_replslot/\n"),
|
||||
local_data_directory);
|
||||
exit(ERR_BAD_RSYNC);
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally, write the recovery.conf file */
|
||||
|
||||
Reference in New Issue
Block a user