Skip to content

Commit e0175b9

Browse files
committed
Merge branch 'master' of git.postgrespro.ru:pgpro-dev/pg_probackup
2 parents 1af622f + 82d7959 commit e0175b9

File tree

5 files changed

+37
-36
lines changed

5 files changed

+37
-36
lines changed

backup.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ typedef struct
4747
const char *to_root;
4848
parray *backup_files_list;
4949
parray *prev_backup_filelist;
50-
const XLogRecPtr *prev_backup_start_lsn;
50+
XLogRecPtr prev_backup_start_lsn;
5151
} backup_files_args;
5252

5353
/*
@@ -101,7 +101,7 @@ do_backup_database(parray *backup_list)
101101
char database_path[MAXPGPATH];
102102
char dst_backup_path[MAXPGPATH];
103103
char label[1024];
104-
XLogRecPtr *prev_backup_start_lsn = NULL;
104+
XLogRecPtr prev_backup_start_lsn = InvalidXLogRecPtr;
105105

106106
pthread_t backup_threads[num_threads];
107107
pthread_t stream_thread;
@@ -128,7 +128,7 @@ do_backup_database(parray *backup_list)
128128
{
129129
prev_backup = catalog_get_last_data_backup(backup_list, current.tli);
130130
if (prev_backup == NULL)
131-
elog(ERROR, "Valid backup on current timeline is not found."
131+
elog(ERROR, "Valid backup on current timeline is not found. "
132132
"Create new FULL backup before an incremental one.");
133133
}
134134

@@ -189,7 +189,7 @@ do_backup_database(parray *backup_list)
189189
prev_backup_filelist = dir_read_file_list(pgdata, prev_backup_filelist_path);
190190

191191
/* If lsn is not NULL, only pages with higher lsn will be copied. */
192-
prev_backup_start_lsn = &prev_backup->start_lsn;
192+
prev_backup_start_lsn = prev_backup->start_lsn;
193193

194194
current.parent_backup = prev_backup->start_time;
195195
pgBackupWriteBackupControlFile(&current);
@@ -432,14 +432,14 @@ do_backup(void)
432432

433433
elog(LOG, "Backup destination is initialized");
434434

435+
/* set the error processing function for the backup process */
436+
pgut_atexit_push(backup_cleanup, NULL);
437+
435438
/* get list of backups already taken */
436439
backup_list = catalog_get_backup_list(INVALID_BACKUP_ID);
437440
if (backup_list == NULL)
438441
elog(ERROR, "Failed to get backup list.");
439442

440-
/* set the error processing function for the backup process */
441-
pgut_atexit_push(backup_cleanup, NULL);
442-
443443
/* backup data */
444444
do_backup_database(backup_list);
445445
pgut_atexit_pop(backup_cleanup, NULL);

data.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ parse_page(const DataPage *page, XLogRecPtr *lsn)
5353
* to the backup file.
5454
*/
5555
static void
56-
backup_data_page(pgFile *file, const XLogRecPtr *prev_backup_start_lsn,
56+
backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
5757
BlockNumber blknum, BlockNumber nblocks,
5858
FILE *in, FILE *out,
5959
pg_crc32 *crc)
@@ -137,9 +137,9 @@ backup_data_page(pgFile *file, const XLogRecPtr *prev_backup_start_lsn,
137137
}
138138

139139
/* If the page hasn't changed since previous backup, don't backup it. */
140-
if (prev_backup_start_lsn
140+
if (!XLogRecPtrIsInvalid(prev_backup_start_lsn)
141141
&& !XLogRecPtrIsInvalid(page_lsn)
142-
&& page_lsn < *prev_backup_start_lsn)
142+
&& page_lsn < prev_backup_start_lsn)
143143
return;
144144

145145
/* Verify checksum */
@@ -194,7 +194,7 @@ backup_data_page(pgFile *file, const XLogRecPtr *prev_backup_start_lsn,
194194
*/
195195
bool
196196
backup_data_file(const char *from_root, const char *to_root,
197-
pgFile *file, const XLogRecPtr *prev_backup_start_lsn)
197+
pgFile *file, XLogRecPtr prev_backup_start_lsn)
198198
{
199199
char to_path[MAXPGPATH];
200200
FILE *in;

dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ dir_read_file_list(const char *root, const char *file_txt)
723723
sscanf(buf, "linked:%s", linked);
724724
ptr = strstr(buf,"segno");
725725
if (ptr)
726-
sscanf(buf, "linked:%s", linked);
726+
sscanf(buf, "segno:%d", &segno);
727727
#ifdef PGPRO_EE
728728
ptr = strstr(buf,"CFS_generation");
729729
sscanf(buf, "CFS_generation:%lu", &generation);

pg_probackup.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ static pgut_option options[] =
107107
int
108108
main(int argc, char *argv[])
109109
{
110-
int i;
110+
char path[MAXPGPATH];
111+
/* Check if backup_path is directory. */
112+
struct stat stat_buf;
113+
int rc = stat(backup_path, &stat_buf);
111114

112115
/* initialize configuration */
113116
pgBackup_init(&current);
@@ -151,7 +154,7 @@ main(int argc, char *argv[])
151154
}
152155

153156
/* Parse command line arguments */
154-
i = pgut_getopt(argc, argv, options);
157+
pgut_getopt(argc, argv, options);
155158

156159
if (backup_path == NULL)
157160
{
@@ -160,27 +163,20 @@ main(int argc, char *argv[])
160163
if (backup_path == NULL)
161164
elog(ERROR, "required parameter not specified: BACKUP_PATH (-B, --backup-path)");
162165
}
163-
else
164-
{
165-
char path[MAXPGPATH];
166-
/* Check if backup_path is directory. */
167-
struct stat stat_buf;
168-
int rc = stat(backup_path, &stat_buf);
169166

170-
/* If rc == -1, there is no file or directory. So it's OK. */
171-
if (rc != -1 && !S_ISDIR(stat_buf.st_mode))
172-
elog(ERROR, "-B, --backup-path must be a path to directory");
167+
/* If rc == -1, there is no file or directory. So it's OK. */
168+
if (rc != -1 && !S_ISDIR(stat_buf.st_mode))
169+
elog(ERROR, "-B, --backup-path must be a path to directory");
173170

174-
/* Do not read options from file or env if we're going to set them */
175-
if (backup_subcmd != CONFIGURE)
176-
{
177-
/* Read options from configuration file */
178-
join_path_components(path, backup_path, BACKUP_CATALOG_CONF_FILE);
179-
pgut_readopt(path, options, ERROR);
171+
/* Do not read options from file or env if we're going to set them */
172+
if (backup_subcmd != CONFIGURE)
173+
{
174+
/* Read options from configuration file */
175+
join_path_components(path, backup_path, BACKUP_CATALOG_CONF_FILE);
176+
pgut_readopt(path, options, ERROR);
180177

181-
/* Read environment variables */
182-
pgut_getopt_env(options);
183-
}
178+
/* Read environment variables */
179+
pgut_getopt_env(options);
184180
}
185181

186182
if (backup_id_string_param != NULL)
@@ -209,10 +205,15 @@ main(int argc, char *argv[])
209205
join_path_components(arclog_path, backup_path, "wal");
210206

211207
/* setup exclusion list for file search */
212-
for (i = 0; pgdata_exclude_dir[i]; i++); /* find first empty slot */
208+
if (!backup_logs)
209+
{
210+
int i;
211+
212+
for (i = 0; pgdata_exclude_dir[i]; i++); /* find first empty slot */
213213

214-
if(!backup_logs)
215-
pgdata_exclude_dir[i++] = "pg_log";
214+
/* Set 'pg_log' in first empty slot */
215+
pgdata_exclude_dir[i] = "pg_log";
216+
}
216217

217218
if (target_time != NULL && target_xid != NULL)
218219
elog(ERROR, "You can't specify recovery-target-time and recovery-target-xid at the same time");

pg_probackup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ extern int pgFileCompareSize(const void *f1, const void *f2);
340340

341341
/* in data.c */
342342
extern bool backup_data_file(const char *from_root, const char *to_root,
343-
pgFile *file, const XLogRecPtr *lsn);
343+
pgFile *file, XLogRecPtr prev_backup_start_lsn);
344344
extern void restore_data_file(const char *from_root, const char *to_root,
345345
pgFile *file, pgBackup *backup);
346346
extern bool is_compressed_data_file(pgFile *file);

0 commit comments

Comments
 (0)