Skip to content

Commit f0703e5

Browse files
committed
Remove ARCLOG_PATH option.
1 parent 6446ace commit f0703e5

File tree

11 files changed

+21
-93
lines changed

11 files changed

+21
-93
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ Example backup (assuming PostgreSQL is running):
104104
```bash
105105
# Init pg_aramn backup folder
106106
pg_arman init -B /home/postgres/backup/pgarman
107-
cat << __EOF__ >> /home/postgres/backup/pgarman/pg_arman.ini
108-
ARCLOG_PATH = '/home/postgres/backup/arman/wal'
109-
__EOF__
110107
# Make full backup with 2 thread and verbose mode.
111108
pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b full -v -j 2
112109
# Validate backup
@@ -142,9 +139,6 @@ Example backup (assuming PostgreSQL is running):
142139
```bash
143140
# Init pg_aramn backup folder
144141
pg_arman init -B /home/postgres/backup/pgarman
145-
cat << __EOF__ >> /home/postgres/backup/pgarman/pg_arman.ini
146-
ARCLOG_PATH = '/home/postgres/backup/arman/wal'
147-
__EOF__
148142
# Make full backup with 2 thread and verbose mode.
149143
pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b full -v -j 2 --stream
150144
# Validate backup

expected/init.out

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@ results/init/backup/
66
results/init/backup/backup/
77
results/init/backup/backup/pg_xlog/
88
results/init/backup/pg_arman.ini
9+
results/init/backup/wal/
910
###### INIT COMMAND TEST-0002 ######
1011
###### success with archive_command and log_directory ######
1112
0
1213
results/init/backup/
1314
results/init/backup/backup/
1415
results/init/backup/backup/pg_xlog/
1516
results/init/backup/pg_arman.ini
17+
results/init/backup/wal/
1618
###### INIT COMMAND TEST-0003 ######
1719
###### success without archive_command ######
18-
WARNING: ARCLOG_PATH is not set because archive_command is empty.Please set ARCLOG_PATH in pg_arman.ini or environmental variable
1920
0
2021
results/init/backup/
2122
results/init/backup/backup/
2223
results/init/backup/backup/pg_xlog/
2324
results/init/backup/pg_arman.ini
25+
results/init/backup/wal/
2426
###### INIT COMMAND TEST-0004 ######
2527
###### failure with backup catalog already existed ######
2628
ERROR: backup catalog already exist. and it's not empty

expected/option.out

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Usage:
1313

1414
Common Options:
1515
-D, --pgdata=PATH location of the database storage area
16-
-A, --arclog-path=PATH location of archive WAL storage area
1716
-B, --backup-path=PATH location of the backup storage area
1817
-c, --check show what would have been done
1918
-j, --threads=NUM num threads for backup and restore
@@ -76,11 +75,6 @@ ERROR: Required parameter not specified: BACKUP_MODE (-b, --backup-mode)
7675
ERROR: invalid backup-mode "bad"
7776
1
7877

79-
###### COMMAND OPTION TEST-0006 ######
80-
###### delete failure without archive path ######
81-
ERROR: delete command needs ARCLOG_PATH (-A, --arclog-path) to be set
82-
1
83-
8478
###### COMMAND OPTION TEST-0007 ######
8579
###### delete failure without DATE ######
8680
ERROR: required delete range option not specified: delete DATE

init.c

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ int
3030
do_init(void)
3131
{
3232
char path[MAXPGPATH];
33+
char arclog_path_dir[MAXPGPATH];
3334
char *log_directory = NULL;
3435
char *archive_command = NULL;
3536
FILE *fp;
@@ -66,51 +67,8 @@ do_init(void)
6667
if (fp == NULL)
6768
elog(ERROR, "cannot create pg_arman.ini: %s", strerror(errno));
6869

69-
/* set ARCLOG_PATH refered with log_directory */
70-
if (arclog_path == NULL && archive_command && archive_command[0])
71-
{
72-
char *command = pgut_strdup(archive_command);
73-
char *begin;
74-
char *end;
75-
char *fname;
76-
77-
/* example: 'cp "%p" /path/to/arclog/"%f"' */
78-
for (begin = command; *begin;)
79-
{
80-
begin = begin + strspn(begin, " \n\r\t\v");
81-
end = begin + strcspn(begin, " \n\r\t\v");
82-
*end = '\0';
83-
84-
if ((fname = strstr(begin, "%f")) != NULL)
85-
{
86-
while (strchr(" \n\r\t\v\"'", *begin))
87-
begin++;
88-
fname--;
89-
while (fname > begin && strchr(" \n\r\t\v\"'/", fname[-1]))
90-
fname--;
91-
*fname = '\0';
92-
93-
if (is_absolute_path(begin))
94-
arclog_path = pgut_strdup(begin);
95-
break;
96-
}
97-
98-
begin = end + 1;
99-
}
100-
101-
free(command);
102-
}
103-
if (arclog_path)
104-
{
105-
fprintf(fp, "ARCLOG_PATH='%s'\n", arclog_path);
106-
elog(INFO, "ARCLOG_PATH is set to '%s'", arclog_path);
107-
}
108-
else if (archive_command && archive_command[0])
109-
elog(WARNING, "ARCLOG_PATH is not set because failed to parse archive_command '%s'."
110-
"Please set ARCLOG_PATH in pg_arman.ini or environmental variable", archive_command);
111-
else
112-
elog(WARNING, "ARCLOG_PATH is not set because archive_command is empty."
113-
"Please set ARCLOG_PATH in pg_arman.ini or environmental variable");
70+
join_path_components(arclog_path_dir, backup_path, "wal");
71+
dir_create_dir(arclog_path_dir, DIR_PERMISSION);
11472

11573
fprintf(fp, "\n");
11674
fclose(fp);

pg_arman.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const char *PROGRAM_EMAIL = "https://github.com/stalkerg/pg_arman/issues";
2222
/* path configuration */
2323
char *backup_path;
2424
char *pgdata;
25-
char *arclog_path = NULL;
25+
char arclog_path[MAXPGPATH];
2626

2727
/* common configuration */
2828
bool check = false;
@@ -57,7 +57,6 @@ static pgut_option options[] =
5757
{
5858
/* directory options */
5959
{ 's', 'D', "pgdata", &pgdata, SOURCE_ENV },
60-
{ 's', 'A', "arclog-path", &arclog_path, SOURCE_ENV },
6160
{ 's', 'B', "backup-path", &backup_path, SOURCE_ENV },
6261
/* common options */
6362
{ 'b', 'c', "check", &check },
@@ -171,18 +170,13 @@ main(int argc, char *argv[])
171170
elog(ERROR, "-B, --backup-path must be an absolute path");
172171
if (pgdata != NULL && !is_absolute_path(pgdata))
173172
elog(ERROR, "-D, --pgdata must be an absolute path");
174-
if (arclog_path != NULL && !is_absolute_path(arclog_path))
175-
elog(ERROR, "-A, --arclog-path must be an absolute path");
176173

177-
/* Sanity checks with commands */
178-
if (pg_strcasecmp(cmd, "delete") == 0 && arclog_path == NULL)
179-
elog(ERROR, "delete command needs ARCLOG_PATH (-A, --arclog-path) to be set");
174+
join_path_components(arclog_path, backup_path, "wal");
180175

181176
/* setup exclusion list for file search */
182177
for (i = 0; pgdata_exclude[i]; i++); /* find first empty slot */
183178

184-
if (arclog_path)
185-
pgdata_exclude[i++] = arclog_path;
179+
pgdata_exclude[i++] = arclog_path;
186180

187181
if(!backup_logs)
188182
pgdata_exclude[i++] = "pg_log";
@@ -241,7 +235,6 @@ pgut_help(bool details)
241235

242236
printf(_("\nCommon Options:\n"));
243237
printf(_(" -D, --pgdata=PATH location of the database storage area\n"));
244-
printf(_(" -A, --arclog-path=PATH location of archive WAL storage area\n"));
245238
printf(_(" -B, --backup-path=PATH location of the backup storage area\n"));
246239
printf(_(" -c, --check show what would have been done\n"));
247240
printf(_(" -j, --threads=NUM num threads for backup and restore\n"));

pg_arman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ typedef union DataPage
196196
/* path configuration */
197197
extern char *backup_path;
198198
extern char *pgdata;
199-
extern char *arclog_path;
199+
extern char arclog_path[MAXPGPATH];
200200

201201
/* common configuration */
202202
extern bool check;

restore.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ do_restore(const char *target_time,
6868
if (pgdata == NULL)
6969
elog(ERROR,
7070
"required parameter not specified: PGDATA (-D, --pgdata)");
71-
if (arclog_path == NULL)
72-
elog(ERROR,
73-
"required parameter not specified: ARCLOG_PATH (-A, --arclog-path)");
7471

7572
elog(LOG, "========================================");
7673
elog(LOG, "restore start");

show.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ do_show(pgBackupRange *range, bool show_all)
2525
* the parent TLI from history field generated by server after
2626
* child timeline is chosen.
2727
*/
28-
if (arclog_path == NULL)
29-
elog(ERROR,
30-
"required parameter not specified: ARCLOG_PATH (-A, --arclog-path)");
31-
3228
if (pgBackupRangeIsSingle(range))
3329
{
3430
pgBackup *backup;

sql/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ BASE_PATH=`pwd`
2626
TEST_BASE=${BASE_PATH}/results/${TEST_NAME}
2727
PGDATA_PATH=${TEST_BASE}/data
2828
BACKUP_PATH=${TEST_BASE}/backup
29-
ARCLOG_PATH=${TEST_BASE}/arclog
29+
ARCLOG_PATH=${BACKUP_PATH}/wal
3030
TBLSPC_PATH=${TEST_BASE}/tblspc
3131
TEST_PGPORT=54321
3232
export PGDATA=${PGDATA_PATH}

sql/init.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
pg_ctl stop -m immediate > /dev/null 2>&1
1212
rm -fr ${PGDATA}
1313
rm -fr ${BACKUP_PATH}
14-
rm -fr ${ARCLOG_PATH} && mkdir -p ${ARCLOG_PATH}
1514

1615
initdb --no-locale > /dev/null 2>&1
1716
cp ${PGDATA}/postgresql.conf ${PGDATA}/postgresql.conf_org

sql/option.sh

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,63 +21,58 @@ echo ''
2121

2222
echo '###### COMMAND OPTION TEST-0003 ######'
2323
echo '###### backup command failure without backup path option ######'
24-
pg_arman backup -A ${ARCLOG_PATH} -b full -p ${TEST_PGPORT};echo $?
24+
pg_arman backup -b full -p ${TEST_PGPORT};echo $?
2525
echo ''
2626

2727
echo '###### COMMAND OPTION TEST-0004 ######'
2828
echo '###### backup command failure without backup mode option ######'
29-
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -p ${TEST_PGPORT};echo $?
29+
pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
3030
echo ''
3131

3232
echo '###### COMMAND OPTION TEST-0005 ######'
3333
echo '###### backup command failure with invalid backup mode option ######'
34-
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -b bad -p ${TEST_PGPORT};echo $?
35-
echo ''
36-
37-
echo '###### COMMAND OPTION TEST-0006 ######'
38-
echo '###### delete failure without archive path ######'
39-
pg_arman delete -B ${BACKUP_PATH};echo $?
34+
pg_arman backup -B ${BACKUP_PATH} -b bad -p ${TEST_PGPORT};echo $?
4035
echo ''
4136

4237
echo '###### COMMAND OPTION TEST-0007 ######'
4338
echo '###### delete failure without DATE ######'
44-
pg_arman delete -B ${BACKUP_PATH} -A ${ARCLOG_PATH};echo $?
39+
pg_arman delete -B ${BACKUP_PATH};echo $?
4540
echo ''
4641

4742
init_backup
4843

4944
echo '###### COMMAND OPTION TEST-0008 ######'
5045
echo '###### syntax error in pg_arman.ini ######'
5146
echo " = INFINITE" >> ${BACKUP_PATH}/pg_arman.ini
52-
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -p ${TEST_PGPORT};echo $?
47+
pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
5348
echo ''
5449

5550
echo '###### COMMAND OPTION TEST-0009 ######'
5651
echo '###### invalid value in pg_arman.ini ######'
5752
init_catalog
5853
echo "BACKUP_MODE=" >> ${BACKUP_PATH}/pg_arman.ini
59-
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -p ${TEST_PGPORT};echo $?
54+
pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
6055
echo ''
6156

6257
echo '###### COMMAND OPTION TEST-0010 ######'
6358
echo '###### invalid value in pg_arman.ini ######'
6459
init_catalog
6560
echo "KEEP_DATA_GENERATIONS=TRUE" >> ${BACKUP_PATH}/pg_arman.ini
66-
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -b full -p ${TEST_PGPORT};echo $?
61+
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $?
6762
echo ''
6863

6964
echo '###### COMMAND OPTION TEST-0011 ######'
7065
echo '###### invalid value in pg_arman.ini ######'
7166
init_catalog
7267
echo "SMOOTH_CHECKPOINT=FOO" >> ${BACKUP_PATH}/pg_arman.ini
73-
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -b full -p ${TEST_PGPORT};echo $?
68+
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $?
7469
echo ''
7570

7671
echo '###### COMMAND OPTION TEST-0012 ######'
7772
echo '###### invalid option in pg_arman.ini ######'
7873
init_catalog
7974
echo "TIMELINEID=1" >> ${BACKUP_PATH}/pg_arman.ini
80-
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -b full -p ${TEST_PGPORT};echo $?
75+
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $?
8176
echo ''
8277

8378
echo '###### COMMAND OPTION TEST-0013 ######'
@@ -86,7 +81,7 @@ init_catalog
8681
mkdir -p ${BACKUP_PATH}/conf_path_a
8782
echo "BACKUP_MODE=ENV_PATH" > ${BACKUP_PATH}/pg_arman.ini
8883
echo "BACKUP_MODE=ENV_PATH_A" > ${BACKUP_PATH}/conf_path_a/pg_arman.ini
89-
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -p ${TEST_PGPORT};echo $?
84+
pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
9085
echo ''
9186

9287
# clean up the temporal test data

0 commit comments

Comments
 (0)