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

Merge branch 'master' of git.postgrespro.ru:pgpro-dev/pg_probackup

This commit is contained in:
Anastasia 2017-04-20 15:22:37 +03:00
commit e0175b98c5
5 changed files with 38 additions and 37 deletions

View File

@ -47,7 +47,7 @@ typedef struct
const char *to_root;
parray *backup_files_list;
parray *prev_backup_filelist;
const XLogRecPtr *prev_backup_start_lsn;
XLogRecPtr prev_backup_start_lsn;
} backup_files_args;
/*
@ -101,7 +101,7 @@ do_backup_database(parray *backup_list)
char database_path[MAXPGPATH];
char dst_backup_path[MAXPGPATH];
char label[1024];
XLogRecPtr *prev_backup_start_lsn = NULL;
XLogRecPtr prev_backup_start_lsn = InvalidXLogRecPtr;
pthread_t backup_threads[num_threads];
pthread_t stream_thread;
@ -128,7 +128,7 @@ do_backup_database(parray *backup_list)
{
prev_backup = catalog_get_last_data_backup(backup_list, current.tli);
if (prev_backup == NULL)
elog(ERROR, "Valid backup on current timeline is not found."
elog(ERROR, "Valid backup on current timeline is not found. "
"Create new FULL backup before an incremental one.");
}
@ -189,7 +189,7 @@ do_backup_database(parray *backup_list)
prev_backup_filelist = dir_read_file_list(pgdata, prev_backup_filelist_path);
/* If lsn is not NULL, only pages with higher lsn will be copied. */
prev_backup_start_lsn = &prev_backup->start_lsn;
prev_backup_start_lsn = prev_backup->start_lsn;
current.parent_backup = prev_backup->start_time;
pgBackupWriteBackupControlFile(&current);
@ -432,14 +432,14 @@ do_backup(void)
elog(LOG, "Backup destination is initialized");
/* set the error processing function for the backup process */
pgut_atexit_push(backup_cleanup, NULL);
/* get list of backups already taken */
backup_list = catalog_get_backup_list(INVALID_BACKUP_ID);
if (backup_list == NULL)
elog(ERROR, "Failed to get backup list.");
/* set the error processing function for the backup process */
pgut_atexit_push(backup_cleanup, NULL);
/* backup data */
do_backup_database(backup_list);
pgut_atexit_pop(backup_cleanup, NULL);

8
data.c
View File

@ -53,7 +53,7 @@ parse_page(const DataPage *page, XLogRecPtr *lsn)
* to the backup file.
*/
static void
backup_data_page(pgFile *file, const XLogRecPtr *prev_backup_start_lsn,
backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
BlockNumber blknum, BlockNumber nblocks,
FILE *in, FILE *out,
pg_crc32 *crc)
@ -137,9 +137,9 @@ backup_data_page(pgFile *file, const XLogRecPtr *prev_backup_start_lsn,
}
/* If the page hasn't changed since previous backup, don't backup it. */
if (prev_backup_start_lsn
if (!XLogRecPtrIsInvalid(prev_backup_start_lsn)
&& !XLogRecPtrIsInvalid(page_lsn)
&& page_lsn < *prev_backup_start_lsn)
&& page_lsn < prev_backup_start_lsn)
return;
/* Verify checksum */
@ -194,7 +194,7 @@ backup_data_page(pgFile *file, const XLogRecPtr *prev_backup_start_lsn,
*/
bool
backup_data_file(const char *from_root, const char *to_root,
pgFile *file, const XLogRecPtr *prev_backup_start_lsn)
pgFile *file, XLogRecPtr prev_backup_start_lsn)
{
char to_path[MAXPGPATH];
FILE *in;

2
dir.c
View File

@ -723,7 +723,7 @@ dir_read_file_list(const char *root, const char *file_txt)
sscanf(buf, "linked:%s", linked);
ptr = strstr(buf,"segno");
if (ptr)
sscanf(buf, "linked:%s", linked);
sscanf(buf, "segno:%d", &segno);
#ifdef PGPRO_EE
ptr = strstr(buf,"CFS_generation");
sscanf(buf, "CFS_generation:%lu", &generation);

View File

@ -107,7 +107,10 @@ static pgut_option options[] =
int
main(int argc, char *argv[])
{
int i;
char path[MAXPGPATH];
/* Check if backup_path is directory. */
struct stat stat_buf;
int rc = stat(backup_path, &stat_buf);
/* initialize configuration */
pgBackup_init(&current);
@ -151,7 +154,7 @@ main(int argc, char *argv[])
}
/* Parse command line arguments */
i = pgut_getopt(argc, argv, options);
pgut_getopt(argc, argv, options);
if (backup_path == NULL)
{
@ -160,27 +163,20 @@ main(int argc, char *argv[])
if (backup_path == NULL)
elog(ERROR, "required parameter not specified: BACKUP_PATH (-B, --backup-path)");
}
else
/* If rc == -1, there is no file or directory. So it's OK. */
if (rc != -1 && !S_ISDIR(stat_buf.st_mode))
elog(ERROR, "-B, --backup-path must be a path to directory");
/* Do not read options from file or env if we're going to set them */
if (backup_subcmd != CONFIGURE)
{
char path[MAXPGPATH];
/* Check if backup_path is directory. */
struct stat stat_buf;
int rc = stat(backup_path, &stat_buf);
/* Read options from configuration file */
join_path_components(path, backup_path, BACKUP_CATALOG_CONF_FILE);
pgut_readopt(path, options, ERROR);
/* If rc == -1, there is no file or directory. So it's OK. */
if (rc != -1 && !S_ISDIR(stat_buf.st_mode))
elog(ERROR, "-B, --backup-path must be a path to directory");
/* Do not read options from file or env if we're going to set them */
if (backup_subcmd != CONFIGURE)
{
/* Read options from configuration file */
join_path_components(path, backup_path, BACKUP_CATALOG_CONF_FILE);
pgut_readopt(path, options, ERROR);
/* Read environment variables */
pgut_getopt_env(options);
}
/* Read environment variables */
pgut_getopt_env(options);
}
if (backup_id_string_param != NULL)
@ -209,10 +205,15 @@ main(int argc, char *argv[])
join_path_components(arclog_path, backup_path, "wal");
/* setup exclusion list for file search */
for (i = 0; pgdata_exclude_dir[i]; i++); /* find first empty slot */
if (!backup_logs)
{
int i;
if(!backup_logs)
pgdata_exclude_dir[i++] = "pg_log";
for (i = 0; pgdata_exclude_dir[i]; i++); /* find first empty slot */
/* Set 'pg_log' in first empty slot */
pgdata_exclude_dir[i] = "pg_log";
}
if (target_time != NULL && target_xid != NULL)
elog(ERROR, "You can't specify recovery-target-time and recovery-target-xid at the same time");

View File

@ -340,7 +340,7 @@ extern int pgFileCompareSize(const void *f1, const void *f2);
/* in data.c */
extern bool backup_data_file(const char *from_root, const char *to_root,
pgFile *file, const XLogRecPtr *lsn);
pgFile *file, XLogRecPtr prev_backup_start_lsn);
extern void restore_data_file(const char *from_root, const char *to_root,
pgFile *file, pgBackup *backup);
extern bool is_compressed_data_file(pgFile *file);