Skip to content

Commit 7ef2945

Browse files
committed
write only completed files to backup_content_control of running backup
1 parent 66a1c64 commit 7ef2945

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

src/backup.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ do_backup_instance(PGconn *backup_conn)
575575

576576
/* Print the list of files to backup catalog */
577577
write_backup_filelist(&current, backup_files_list, instance_config.pgdata,
578-
NULL, external_dirs);
578+
external_dirs);
579579

580580
/* clean external directories list */
581581
if (external_dirs)
@@ -1999,18 +1999,17 @@ backup_files(void *arg)
19991999
struct stat buf;
20002000
pgFile *file = (pgFile *) parray_get(arguments->files_list, i);
20012001

2002-
20032002
if (arguments->thread_num == 1)
20042003
{
20052004
/* update every 10 seconds */
20062005
if ((difftime(time(NULL), prev_time)) > 10)
20072006
{
20082007
prev_time = time(NULL);
2009-
elog(INFO, "write_backup_filelist N=%ld, starttime %ld, time %ld",
2010-
parray_num(backup_files_list), current.start_time, prev_time);
2008+
elog(INFO, "write_backup_filelist N=%d, starttime %ld, time %ld",
2009+
n_backup_files_list, current.start_time, prev_time);
20112010

2012-
write_backup_filelist(&current, backup_files_list, instance_config.pgdata,
2013-
NULL, arguments->external_dirs);
2011+
write_backup_filelist(&current, arguments->files_list, instance_config.pgdata,
2012+
arguments->external_dirs);
20142013
}
20152014
}
20162015

@@ -2146,6 +2145,7 @@ backup_files(void *arg)
21462145
}
21472146
}
21482147

2148+
file->backuped = true;
21492149
elog(VERBOSE, "File \"%s\". Copied "INT64_FORMAT " bytes",
21502150
file->path, file->write_size);
21512151
}

src/catalog.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ write_backup(pgBackup *backup)
630630
*/
631631
void
632632
write_backup_filelist(pgBackup *backup, parray *files, const char *root,
633-
const char *external_prefix, parray *external_list)
633+
parray *external_list)
634634
{
635635
FILE *out;
636636
char path[MAXPGPATH];
@@ -657,12 +657,15 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
657657
char line[BLCKSZ];
658658
int len = 0;
659659

660+
i++;
661+
if (!file->backuped)
662+
continue;
663+
660664
/* omit root directory portion */
661665
if (root && strstr(path, root) == path)
662666
path = GetRelativePath(path, root);
663-
else if (file->external_dir_num && !external_prefix)
667+
else if (file->external_dir_num && external_list)
664668
{
665-
Assert(external_list);
666669
path = GetRelativePath(path, parray_get(external_list,
667670
file->external_dir_num - 1));
668671
}
@@ -707,8 +710,6 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
707710
/* reset write_len */
708711
write_len = 0;
709712
}
710-
711-
i++;
712713
}
713714

714715
/* write what is left in the buffer to file */

src/merge.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,7 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
368368
else
369369
to_backup->wal_bytes = BYTES_INVALID;
370370

371-
write_backup_filelist(to_backup, files, from_database_path,
372-
from_external_prefix, NULL);
371+
write_backup_filelist(to_backup, files, from_database_path, NULL);
373372
write_backup(to_backup);
374373

375374
delete_source_backup:

src/pg_probackup.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ typedef struct pgFile
146146
datapagemap_t pagemap; /* bitmap of pages updated since previous backup */
147147
bool pagemap_isabsent; /* Used to mark files with unknown state of pagemap,
148148
* i.e. datafiles without _ptrack */
149+
150+
/* state during bakup */
151+
bool backuped; /* is file already completely copied into destination backup? */
149152
} pgFile;
150153

151154
/* Special values of datapagemap_t bitmapsize */
@@ -555,8 +558,7 @@ extern pgBackup *catalog_get_last_data_backup(parray *backup_list,
555558
TimeLineID tli);
556559
extern void pgBackupWriteControl(FILE *out, pgBackup *backup);
557560
extern void write_backup_filelist(pgBackup *backup, parray *files,
558-
const char *root, const char *external_prefix,
559-
parray *external_list);
561+
const char *root, parray *external_list);
560562

561563
extern void pgBackupGetPath(const pgBackup *backup, char *path, size_t len,
562564
const char *subdir);

0 commit comments

Comments
 (0)