Skip to content

Commit 0a2e5be

Browse files
committed
[Issue #219] Make add-instance idempotent
1 parent 4e1ec27 commit 0a2e5be

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/init.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,31 @@ do_add_instance(InstanceConfig *instance)
6767

6868
/* Ensure that all root directories already exist */
6969
if (access(backup_path, F_OK) != 0)
70-
elog(ERROR, "%s directory does not exist.", backup_path);
70+
elog(ERROR, "Directory does not exist: '%s'", backup_path);
7171

7272
join_path_components(path, backup_path, BACKUPS_DIR);
7373
if (access(path, F_OK) != 0)
74-
elog(ERROR, "%s directory does not exist.", path);
74+
elog(ERROR, "Directory does not exist: '%s'", path);
7575

7676
join_path_components(arclog_path_dir, backup_path, "wal");
7777
if (access(arclog_path_dir, F_OK) != 0)
78-
elog(ERROR, "%s directory does not exist.", arclog_path_dir);
78+
elog(ERROR, "Directory does not exist: '%s'", arclog_path_dir);
7979

80-
/* Create directory for data files of this specific instance */
8180
if (stat(instance->backup_instance_path, &st) == 0 && S_ISDIR(st.st_mode))
82-
elog(ERROR, "instance '%s' already exists", instance->backup_instance_path);
83-
dir_create_dir(instance->backup_instance_path, DIR_PERMISSION);
81+
elog(ERROR, "Instance '%s' backup directory already exists: '%s'",
82+
instance->name, instance->backup_instance_path);
8483

8584
/*
8685
* Create directory for wal files of this specific instance.
8786
* Existence check is extra paranoid because if we don't have such a
8887
* directory in data dir, we shouldn't have it in wal as well.
8988
*/
9089
if (stat(instance->arclog_path, &st) == 0 && S_ISDIR(st.st_mode))
91-
elog(ERROR, "arclog_path '%s' already exists", instance->arclog_path);
90+
elog(ERROR, "Instance '%s' WAL archive directory already exists: '%s'",
91+
instance->name, instance->arclog_path);
92+
93+
/* Create directory for data files of this specific instance */
94+
dir_create_dir(instance->backup_instance_path, DIR_PERMISSION);
9295
dir_create_dir(instance->arclog_path, DIR_PERMISSION);
9396

9497
/*

0 commit comments

Comments
 (0)