diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index 12b5e24cac505016b4bfa059117b94a91f91d333..ba8d173357e036e9d9242a2a4a9d640c59780318 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -303,6 +303,14 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir) } qsort(walFiles, nWalFiles, sizeof(char *), compareWalFileNames); + /* + * There must be at least one xlog file in the pg_xlog directory, + * since we are doing backup-including-xlog. + */ + if (nWalFiles < 1) + ereport(ERROR, + (errmsg("could not find any WAL files"))); + /* * Sanity check: the first and last segment should cover startptr and * endptr, with no gaps in between.