1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-24 08:52:38 +02:00

Bunch of small fixes. Version 2.0.1

This commit is contained in:
Anastasia 2017-07-05 17:36:22 +03:00
parent be95e17fac
commit 9f91dfc5bb
6 changed files with 72 additions and 62 deletions

View File

@ -43,26 +43,31 @@ subdir=contrib/pg_probackup
top_builddir=../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
ifeq ("$(top_srcdir)","../..")
srchome="$(top_srcdir)/.."
else
srchome="$(top_srcdir)"
endif
# Those files are symlinked from the PostgreSQL sources.
src/xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/xlogreader.c
rm -f $@ && $(LN_S) ../$< ./src/xlogreader.c
src/datapagemap.c: % : $(top_srcdir)/src/bin/pg_rewind/datapagemap.c
rm -f $@ && $(LN_S) ../$< ./src/datapagemap.c
src/datapagemap.h: % : $(top_srcdir)/src/bin/pg_rewind/datapagemap.h
rm -f $@ && $(LN_S) ../$< src/datapagemap.h
src/logging.h: % : $(top_srcdir)/src/bin/pg_rewind/logging.h
rm -f $@ && $(LN_S) ../$< ./src
src/receivelog.c: % : $(top_srcdir)/src/bin/pg_basebackup/receivelog.c
rm -f $@ && $(LN_S) ../$< ./src
src/receivelog.h: % : $(top_srcdir)/src/bin/pg_basebackup/receivelog.h
rm -f $@ && $(LN_S) ../$< ./src
src/streamutil.c: % : $(top_srcdir)/src/bin/pg_basebackup/streamutil.c
rm -f $@ && $(LN_S) ../$< ./src
src/streamutil.h: % : $(top_srcdir)/src/bin/pg_basebackup/streamutil.h
rm -f $@ && $(LN_S) ../$< ./src
src/xlogreader.c: $(top_srcdir)/src/backend/access/transam/xlogreader.c
rm -f $@ && $(LN_S) $(srchome)/src/backend/access/transam/xlogreader.c $@
src/datapagemap.c: $(top_srcdir)/src/bin/pg_rewind/datapagemap.c
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_rewind/datapagemap.c $@
src/datapagemap.h: $(top_srcdir)/src/bin/pg_rewind/datapagemap.h
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_rewind/datapagemap.h $@
src/logging.h: $(top_srcdir)/src/bin/pg_rewind/logging.h
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_rewind/logging.h $@
src/receivelog.c: $(top_srcdir)/src/bin/pg_basebackup/receivelog.c
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/receivelog.c $@
src/receivelog.h: $(top_srcdir)/src/bin/pg_basebackup/receivelog.h
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/receivelog.h $@
src/streamutil.c: $(top_srcdir)/src/bin/pg_basebackup/streamutil.c
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/streamutil.c $@
src/streamutil.h: $(top_srcdir)/src/bin/pg_basebackup/streamutil.h
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/streamutil.h $@
endif
PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS}
PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS} -Isrc
override CPPFLAGS := -DFRONTEND $(CPPFLAGS) $(PG_CPPFLAGS)
PG_LIBS = $(libpq_pgport) ${PTHREAD_CFLAGS}

View File

@ -256,7 +256,7 @@ do_backup_database(parray *backup_list)
if (ptrack_lsn > prev_backup->stop_lsn)
{
elog(ERROR, "LSN from ptrack_control %lx differs from LSN of previous ptrack backup %lx.\n"
elog(ERROR, "LSN from ptrack_control %lx differs from LSN of previous backup %lx.\n"
"Create new full backup before an incremental one.",
ptrack_lsn, prev_backup->start_lsn);
}
@ -436,6 +436,9 @@ do_backup(void)
if (!current.stream && !pg_archive_enabled())
elog(ERROR, "Archiving must be enabled for archive backup");
if (current.backup_mode == BACKUP_MODE_DIFF_PAGE && !pg_archive_enabled())
elog(ERROR, "Archiving must be enabled for PAGE backup");
if (from_replica)
{
/* Check master connection options */

View File

@ -28,10 +28,6 @@ do_delete(time_t backup_id)
XLogRecPtr oldest_lsn = InvalidXLogRecPtr;
TimeLineID oldest_tli = 0;
/* DATE are always required */
if (backup_id == 0)
elog(ERROR, "required backup ID not specified");
/* Get exclusive lock of backup catalog */
catalog_lock();
@ -40,55 +36,60 @@ do_delete(time_t backup_id)
if (backup_list == NULL)
elog(ERROR, "Failed to get backup list.");
delete_list = parray_new();
/* Find backup to be deleted and make increment backups array to be deleted */
for (i = (int) parray_num(backup_list) - 1; i >= 0; i--)
if (backup_id != 0)
{
pgBackup *backup = (pgBackup *) parray_get(backup_list, (size_t) i);
delete_list = parray_new();
if (backup->start_time == backup_id)
/* Find backup to be deleted and make increment backups array to be deleted */
for (i = (int) parray_num(backup_list) - 1; i >= 0; i--)
{
parray_append(delete_list, backup);
pgBackup *backup = (pgBackup *) parray_get(backup_list, (size_t) i);
/*
* Do not remove next backups, if target backup was finished
* incorrectly.
*/
if (backup->status == BACKUP_STATUS_ERROR)
break;
/* Save backup id to retreive increment backups */
parent_id = backup->start_time;
backup_found = true;
}
else if (backup_found)
{
if (backup->backup_mode != BACKUP_MODE_FULL &&
backup->parent_backup == parent_id)
if (backup->start_time == backup_id)
{
/* Append to delete list increment backup */
parray_append(delete_list, backup);
/*
* Do not remove next backups, if target backup was finished
* incorrectly.
*/
if (backup->status == BACKUP_STATUS_ERROR)
break;
/* Save backup id to retreive increment backups */
parent_id = backup->start_time;
backup_found = true;
}
else if (backup_found)
{
if (backup->backup_mode != BACKUP_MODE_FULL &&
backup->parent_backup == parent_id)
{
/* Append to delete list increment backup */
parray_append(delete_list, backup);
/* Save backup id to retreive increment backups */
parent_id = backup->start_time;
}
else
break;
}
else
break;
}
}
if (parray_num(delete_list) == 0)
elog(ERROR, "no backup found, cannot delete");
if (parray_num(delete_list) == 0)
elog(ERROR, "no backup found, cannot delete");
/* Delete backups from the end of list */
for (i = (int) parray_num(delete_list) - 1; i >= 0; i--)
{
pgBackup *backup = (pgBackup *) parray_get(delete_list, (size_t) i);
/* Delete backups from the end of list */
for (i = (int) parray_num(delete_list) - 1; i >= 0; i--)
{
pgBackup *backup = (pgBackup *) parray_get(delete_list, (size_t) i);
if (interrupted)
elog(ERROR, "interrupted during delete backup");
if (interrupted)
elog(ERROR, "interrupted during delete backup");
pgBackupDeleteFiles(backup);
pgBackupDeleteFiles(backup);
}
parray_free(delete_list);
}
/* Clean WAL segments */
@ -111,7 +112,6 @@ do_delete(time_t backup_id)
}
/* cleanup */
parray_free(delete_list);
parray_walk(backup_list, pgBackupFree);
parray_free(backup_list);

View File

@ -302,9 +302,9 @@ help_set_config(void)
printf(_("\n Replica options:\n"));
printf(_(" --master-db=db_name database to connect to master\n"));
printf(_(" --master-host=host_name=host_name database server host of master\n"));
printf(_(" --master-host=host_name database server host of master\n"));
printf(_(" --master-port=port=port database server port of master\n"));
printf(_(" --master-user=user_name=user_name user name to connect to master\n"));
printf(_(" --master-user=user_name user name to connect to master\n"));
printf(_(" --replica-timeout=timeout wait timeout for WAL segment streaming through replication\n"));
}

View File

@ -17,7 +17,7 @@
#include <sys/stat.h>
#include <unistd.h>
const char *PROGRAM_VERSION = "2.0.0";
const char *PROGRAM_VERSION = "2.0.1";
const char *PROGRAM_URL = "https://github.com/postgrespro/pg_probackup";
const char *PROGRAM_EMAIL = "https://github.com/postgrespro/pg_probackup/issues";
@ -401,6 +401,8 @@ main(int argc, char *argv[])
case DELETE:
if (delete_expired && backup_id_string_param)
elog(ERROR, "You cannot specify --delete-expired and --backup-id options together");
if (!delete_expired && !delete_wal && !backup_id_string_param)
elog(ERROR, "You must specify at least one of the delete options: --expired |--wal |--backup_id");
if (delete_expired)
return do_retention_purge();
else

View File

@ -1 +1 @@
pg_probackup 2.0.0
pg_probackup 2.0.1