1
0
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:
Arthur Zakirov 2019-04-26 11:33:34 +03:00
parent d489cc700e
commit 32d283f712
3 changed files with 16 additions and 7 deletions

View File

@ -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++)
{

View File

@ -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

View File

@ -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);