mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-12-04 10:44:46 +02:00
Check for existance of an external directory
This commit is contained in:
parent
d489cc700e
commit
32d283f712
@ -888,7 +888,8 @@ do_backup_instance(void)
|
||||
/* Scan backup PG_XLOG_DIR */
|
||||
xlog_files_list = parray_new();
|
||||
join_path_components(pg_xlog_path, database_path, PG_XLOG_DIR);
|
||||
dir_list_file(xlog_files_list, pg_xlog_path, false, true, false, 0, FIO_BACKUP_HOST);
|
||||
dir_list_file(xlog_files_list, pg_xlog_path, false, true, false, 0,
|
||||
FIO_BACKUP_HOST);
|
||||
|
||||
for (i = 0; i < parray_num(xlog_files_list); i++)
|
||||
{
|
||||
|
17
src/dir.c
17
src/dir.c
@ -163,13 +163,14 @@ dir_create_dir(const char *dir, mode_t mode)
|
||||
}
|
||||
|
||||
pgFile *
|
||||
pgFileNew(const char *path, bool omit_symlink, int external_dir_num, fio_location location)
|
||||
pgFileNew(const char *path, bool omit_symlink, int external_dir_num,
|
||||
fio_location location)
|
||||
{
|
||||
struct stat st;
|
||||
pgFile *file;
|
||||
|
||||
/* stat the file */
|
||||
if (fio_stat(path, &st, omit_symlink, location) < 0)
|
||||
/* stat the file */
|
||||
if (fio_stat(path, &st, omit_symlink, location) < 0)
|
||||
{
|
||||
/* file not found is not an error case */
|
||||
if (errno == ENOENT)
|
||||
@ -475,11 +476,17 @@ dir_list_file(parray *files, const char *root, bool exclude, bool omit_symlink,
|
||||
|
||||
file = pgFileNew(root, omit_symlink, external_dir_num, location);
|
||||
if (file == NULL)
|
||||
return;
|
||||
{
|
||||
/* For external directory this is not ok */
|
||||
if (external_dir_num > 0)
|
||||
elog(ERROR, "Exteral directory is not found: %s", root);
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
if (!S_ISDIR(file->mode))
|
||||
{
|
||||
if (external_dir_num)
|
||||
if (external_dir_num > 0)
|
||||
elog(ERROR, " --external-dirs option \"%s\": directory or symbolic link expected",
|
||||
file->path);
|
||||
else
|
||||
|
@ -640,7 +640,8 @@ remove_deleted_files(pgBackup *backup)
|
||||
|
||||
/* Get list of files actually existing in target database */
|
||||
files_restored = parray_new();
|
||||
dir_list_file(files_restored, instance_config.pgdata, true, true, false, 0, FIO_BACKUP_HOST);
|
||||
dir_list_file(files_restored, instance_config.pgdata, true, true, false, 0,
|
||||
FIO_BACKUP_HOST);
|
||||
/* To delete from leaf, sort in reversed order */
|
||||
parray_qsort(files_restored, pgFileComparePathDesc);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user