1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-02-09 14:33:17 +02:00

Remove ARCLOG_PATH option.

This commit is contained in:
stalkerg 2016-10-18 20:22:53 +03:00
parent 6446aceec0
commit f0703e527c
11 changed files with 21 additions and 93 deletions

View File

@ -104,9 +104,6 @@ Example backup (assuming PostgreSQL is running):
```bash
# Init pg_aramn backup folder
pg_arman init -B /home/postgres/backup/pgarman
cat << __EOF__ >> /home/postgres/backup/pgarman/pg_arman.ini
ARCLOG_PATH = '/home/postgres/backup/arman/wal'
__EOF__
# Make full backup with 2 thread and verbose mode.
pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b full -v -j 2
# Validate backup
@ -142,9 +139,6 @@ Example backup (assuming PostgreSQL is running):
```bash
# Init pg_aramn backup folder
pg_arman init -B /home/postgres/backup/pgarman
cat << __EOF__ >> /home/postgres/backup/pgarman/pg_arman.ini
ARCLOG_PATH = '/home/postgres/backup/arman/wal'
__EOF__
# Make full backup with 2 thread and verbose mode.
pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b full -v -j 2 --stream
# Validate backup

View File

@ -6,6 +6,7 @@ results/init/backup/
results/init/backup/backup/
results/init/backup/backup/pg_xlog/
results/init/backup/pg_arman.ini
results/init/backup/wal/
###### INIT COMMAND TEST-0002 ######
###### success with archive_command and log_directory ######
0
@ -13,14 +14,15 @@ results/init/backup/
results/init/backup/backup/
results/init/backup/backup/pg_xlog/
results/init/backup/pg_arman.ini
results/init/backup/wal/
###### INIT COMMAND TEST-0003 ######
###### success without archive_command ######
WARNING: ARCLOG_PATH is not set because archive_command is empty.Please set ARCLOG_PATH in pg_arman.ini or environmental variable
0
results/init/backup/
results/init/backup/backup/
results/init/backup/backup/pg_xlog/
results/init/backup/pg_arman.ini
results/init/backup/wal/
###### INIT COMMAND TEST-0004 ######
###### failure with backup catalog already existed ######
ERROR: backup catalog already exist. and it's not empty

View File

@ -13,7 +13,6 @@ Usage:
Common Options:
-D, --pgdata=PATH location of the database storage area
-A, --arclog-path=PATH location of archive WAL storage area
-B, --backup-path=PATH location of the backup storage area
-c, --check show what would have been done
-j, --threads=NUM num threads for backup and restore
@ -76,11 +75,6 @@ ERROR: Required parameter not specified: BACKUP_MODE (-b, --backup-mode)
ERROR: invalid backup-mode "bad"
1
###### COMMAND OPTION TEST-0006 ######
###### delete failure without archive path ######
ERROR: delete command needs ARCLOG_PATH (-A, --arclog-path) to be set
1
###### COMMAND OPTION TEST-0007 ######
###### delete failure without DATE ######
ERROR: required delete range option not specified: delete DATE

48
init.c
View File

@ -30,6 +30,7 @@ int
do_init(void)
{
char path[MAXPGPATH];
char arclog_path_dir[MAXPGPATH];
char *log_directory = NULL;
char *archive_command = NULL;
FILE *fp;
@ -66,51 +67,8 @@ do_init(void)
if (fp == NULL)
elog(ERROR, "cannot create pg_arman.ini: %s", strerror(errno));
/* set ARCLOG_PATH refered with log_directory */
if (arclog_path == NULL && archive_command && archive_command[0])
{
char *command = pgut_strdup(archive_command);
char *begin;
char *end;
char *fname;
/* example: 'cp "%p" /path/to/arclog/"%f"' */
for (begin = command; *begin;)
{
begin = begin + strspn(begin, " \n\r\t\v");
end = begin + strcspn(begin, " \n\r\t\v");
*end = '\0';
if ((fname = strstr(begin, "%f")) != NULL)
{
while (strchr(" \n\r\t\v\"'", *begin))
begin++;
fname--;
while (fname > begin && strchr(" \n\r\t\v\"'/", fname[-1]))
fname--;
*fname = '\0';
if (is_absolute_path(begin))
arclog_path = pgut_strdup(begin);
break;
}
begin = end + 1;
}
free(command);
}
if (arclog_path)
{
fprintf(fp, "ARCLOG_PATH='%s'\n", arclog_path);
elog(INFO, "ARCLOG_PATH is set to '%s'", arclog_path);
}
else if (archive_command && archive_command[0])
elog(WARNING, "ARCLOG_PATH is not set because failed to parse archive_command '%s'."
"Please set ARCLOG_PATH in pg_arman.ini or environmental variable", archive_command);
else
elog(WARNING, "ARCLOG_PATH is not set because archive_command is empty."
"Please set ARCLOG_PATH in pg_arman.ini or environmental variable");
join_path_components(arclog_path_dir, backup_path, "wal");
dir_create_dir(arclog_path_dir, DIR_PERMISSION);
fprintf(fp, "\n");
fclose(fp);

View File

@ -22,7 +22,7 @@ const char *PROGRAM_EMAIL = "https://github.com/stalkerg/pg_arman/issues";
/* path configuration */
char *backup_path;
char *pgdata;
char *arclog_path = NULL;
char arclog_path[MAXPGPATH];
/* common configuration */
bool check = false;
@ -57,7 +57,6 @@ static pgut_option options[] =
{
/* directory options */
{ 's', 'D', "pgdata", &pgdata, SOURCE_ENV },
{ 's', 'A', "arclog-path", &arclog_path, SOURCE_ENV },
{ 's', 'B', "backup-path", &backup_path, SOURCE_ENV },
/* common options */
{ 'b', 'c', "check", &check },
@ -171,18 +170,13 @@ main(int argc, char *argv[])
elog(ERROR, "-B, --backup-path must be an absolute path");
if (pgdata != NULL && !is_absolute_path(pgdata))
elog(ERROR, "-D, --pgdata must be an absolute path");
if (arclog_path != NULL && !is_absolute_path(arclog_path))
elog(ERROR, "-A, --arclog-path must be an absolute path");
/* Sanity checks with commands */
if (pg_strcasecmp(cmd, "delete") == 0 && arclog_path == NULL)
elog(ERROR, "delete command needs ARCLOG_PATH (-A, --arclog-path) to be set");
join_path_components(arclog_path, backup_path, "wal");
/* setup exclusion list for file search */
for (i = 0; pgdata_exclude[i]; i++); /* find first empty slot */
if (arclog_path)
pgdata_exclude[i++] = arclog_path;
pgdata_exclude[i++] = arclog_path;
if(!backup_logs)
pgdata_exclude[i++] = "pg_log";
@ -241,7 +235,6 @@ pgut_help(bool details)
printf(_("\nCommon Options:\n"));
printf(_(" -D, --pgdata=PATH location of the database storage area\n"));
printf(_(" -A, --arclog-path=PATH location of archive WAL storage area\n"));
printf(_(" -B, --backup-path=PATH location of the backup storage area\n"));
printf(_(" -c, --check show what would have been done\n"));
printf(_(" -j, --threads=NUM num threads for backup and restore\n"));

View File

@ -196,7 +196,7 @@ typedef union DataPage
/* path configuration */
extern char *backup_path;
extern char *pgdata;
extern char *arclog_path;
extern char arclog_path[MAXPGPATH];
/* common configuration */
extern bool check;

View File

@ -68,9 +68,6 @@ do_restore(const char *target_time,
if (pgdata == NULL)
elog(ERROR,
"required parameter not specified: PGDATA (-D, --pgdata)");
if (arclog_path == NULL)
elog(ERROR,
"required parameter not specified: ARCLOG_PATH (-A, --arclog-path)");
elog(LOG, "========================================");
elog(LOG, "restore start");

4
show.c
View File

@ -25,10 +25,6 @@ do_show(pgBackupRange *range, bool show_all)
* the parent TLI from history field generated by server after
* child timeline is chosen.
*/
if (arclog_path == NULL)
elog(ERROR,
"required parameter not specified: ARCLOG_PATH (-A, --arclog-path)");
if (pgBackupRangeIsSingle(range))
{
pgBackup *backup;

View File

@ -26,7 +26,7 @@ BASE_PATH=`pwd`
TEST_BASE=${BASE_PATH}/results/${TEST_NAME}
PGDATA_PATH=${TEST_BASE}/data
BACKUP_PATH=${TEST_BASE}/backup
ARCLOG_PATH=${TEST_BASE}/arclog
ARCLOG_PATH=${BACKUP_PATH}/wal
TBLSPC_PATH=${TEST_BASE}/tblspc
TEST_PGPORT=54321
export PGDATA=${PGDATA_PATH}

View File

@ -11,7 +11,6 @@
pg_ctl stop -m immediate > /dev/null 2>&1
rm -fr ${PGDATA}
rm -fr ${BACKUP_PATH}
rm -fr ${ARCLOG_PATH} && mkdir -p ${ARCLOG_PATH}
initdb --no-locale > /dev/null 2>&1
cp ${PGDATA}/postgresql.conf ${PGDATA}/postgresql.conf_org

View File

@ -21,27 +21,22 @@ echo ''
echo '###### COMMAND OPTION TEST-0003 ######'
echo '###### backup command failure without backup path option ######'
pg_arman backup -A ${ARCLOG_PATH} -b full -p ${TEST_PGPORT};echo $?
pg_arman backup -b full -p ${TEST_PGPORT};echo $?
echo ''
echo '###### COMMAND OPTION TEST-0004 ######'
echo '###### backup command failure without backup mode option ######'
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -p ${TEST_PGPORT};echo $?
pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
echo ''
echo '###### COMMAND OPTION TEST-0005 ######'
echo '###### backup command failure with invalid backup mode option ######'
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -b bad -p ${TEST_PGPORT};echo $?
echo ''
echo '###### COMMAND OPTION TEST-0006 ######'
echo '###### delete failure without archive path ######'
pg_arman delete -B ${BACKUP_PATH};echo $?
pg_arman backup -B ${BACKUP_PATH} -b bad -p ${TEST_PGPORT};echo $?
echo ''
echo '###### COMMAND OPTION TEST-0007 ######'
echo '###### delete failure without DATE ######'
pg_arman delete -B ${BACKUP_PATH} -A ${ARCLOG_PATH};echo $?
pg_arman delete -B ${BACKUP_PATH};echo $?
echo ''
init_backup
@ -49,35 +44,35 @@ init_backup
echo '###### COMMAND OPTION TEST-0008 ######'
echo '###### syntax error in pg_arman.ini ######'
echo " = INFINITE" >> ${BACKUP_PATH}/pg_arman.ini
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -p ${TEST_PGPORT};echo $?
pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
echo ''
echo '###### COMMAND OPTION TEST-0009 ######'
echo '###### invalid value in pg_arman.ini ######'
init_catalog
echo "BACKUP_MODE=" >> ${BACKUP_PATH}/pg_arman.ini
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -p ${TEST_PGPORT};echo $?
pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
echo ''
echo '###### COMMAND OPTION TEST-0010 ######'
echo '###### invalid value in pg_arman.ini ######'
init_catalog
echo "KEEP_DATA_GENERATIONS=TRUE" >> ${BACKUP_PATH}/pg_arman.ini
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -b full -p ${TEST_PGPORT};echo $?
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $?
echo ''
echo '###### COMMAND OPTION TEST-0011 ######'
echo '###### invalid value in pg_arman.ini ######'
init_catalog
echo "SMOOTH_CHECKPOINT=FOO" >> ${BACKUP_PATH}/pg_arman.ini
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -b full -p ${TEST_PGPORT};echo $?
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $?
echo ''
echo '###### COMMAND OPTION TEST-0012 ######'
echo '###### invalid option in pg_arman.ini ######'
init_catalog
echo "TIMELINEID=1" >> ${BACKUP_PATH}/pg_arman.ini
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -b full -p ${TEST_PGPORT};echo $?
pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $?
echo ''
echo '###### COMMAND OPTION TEST-0013 ######'
@ -86,7 +81,7 @@ init_catalog
mkdir -p ${BACKUP_PATH}/conf_path_a
echo "BACKUP_MODE=ENV_PATH" > ${BACKUP_PATH}/pg_arman.ini
echo "BACKUP_MODE=ENV_PATH_A" > ${BACKUP_PATH}/conf_path_a/pg_arman.ini
pg_arman backup -B ${BACKUP_PATH} -A ${ARCLOG_PATH} -p ${TEST_PGPORT};echo $?
pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $?
echo ''
# clean up the temporal test data