1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-01-22 11:44:34 +02:00

write only completed files to backup_content_control of running backup

This commit is contained in:
Anastasia 2019-06-11 12:58:50 +03:00
parent 66a1c643d5
commit 7ef294501a
4 changed files with 17 additions and 15 deletions

View File

@ -575,7 +575,7 @@ do_backup_instance(PGconn *backup_conn)
/* Print the list of files to backup catalog */ /* Print the list of files to backup catalog */
write_backup_filelist(&current, backup_files_list, instance_config.pgdata, write_backup_filelist(&current, backup_files_list, instance_config.pgdata,
NULL, external_dirs); external_dirs);
/* clean external directories list */ /* clean external directories list */
if (external_dirs) if (external_dirs)
@ -1999,18 +1999,17 @@ backup_files(void *arg)
struct stat buf; struct stat buf;
pgFile *file = (pgFile *) parray_get(arguments->files_list, i); pgFile *file = (pgFile *) parray_get(arguments->files_list, i);
if (arguments->thread_num == 1) if (arguments->thread_num == 1)
{ {
/* update every 10 seconds */ /* update every 10 seconds */
if ((difftime(time(NULL), prev_time)) > 10) if ((difftime(time(NULL), prev_time)) > 10)
{ {
prev_time = time(NULL); prev_time = time(NULL);
elog(INFO, "write_backup_filelist N=%ld, starttime %ld, time %ld", elog(INFO, "write_backup_filelist N=%d, starttime %ld, time %ld",
parray_num(backup_files_list), current.start_time, prev_time); n_backup_files_list, current.start_time, prev_time);
write_backup_filelist(&current, backup_files_list, instance_config.pgdata, write_backup_filelist(&current, arguments->files_list, instance_config.pgdata,
NULL, arguments->external_dirs); arguments->external_dirs);
} }
} }
@ -2146,6 +2145,7 @@ backup_files(void *arg)
} }
} }
file->backuped = true;
elog(VERBOSE, "File \"%s\". Copied "INT64_FORMAT " bytes", elog(VERBOSE, "File \"%s\". Copied "INT64_FORMAT " bytes",
file->path, file->write_size); file->path, file->write_size);
} }

View File

@ -630,7 +630,7 @@ write_backup(pgBackup *backup)
*/ */
void void
write_backup_filelist(pgBackup *backup, parray *files, const char *root, write_backup_filelist(pgBackup *backup, parray *files, const char *root,
const char *external_prefix, parray *external_list) parray *external_list)
{ {
FILE *out; FILE *out;
char path[MAXPGPATH]; char path[MAXPGPATH];
@ -657,12 +657,15 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
char line[BLCKSZ]; char line[BLCKSZ];
int len = 0; int len = 0;
i++;
if (!file->backuped)
continue;
/* omit root directory portion */ /* omit root directory portion */
if (root && strstr(path, root) == path) if (root && strstr(path, root) == path)
path = GetRelativePath(path, root); path = GetRelativePath(path, root);
else if (file->external_dir_num && !external_prefix) else if (file->external_dir_num && external_list)
{ {
Assert(external_list);
path = GetRelativePath(path, parray_get(external_list, path = GetRelativePath(path, parray_get(external_list,
file->external_dir_num - 1)); file->external_dir_num - 1));
} }
@ -707,8 +710,6 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
/* reset write_len */ /* reset write_len */
write_len = 0; write_len = 0;
} }
i++;
} }
/* write what is left in the buffer to file */ /* write what is left in the buffer to file */

View File

@ -368,8 +368,7 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
else else
to_backup->wal_bytes = BYTES_INVALID; to_backup->wal_bytes = BYTES_INVALID;
write_backup_filelist(to_backup, files, from_database_path, write_backup_filelist(to_backup, files, from_database_path, NULL);
from_external_prefix, NULL);
write_backup(to_backup); write_backup(to_backup);
delete_source_backup: delete_source_backup:

View File

@ -146,6 +146,9 @@ typedef struct pgFile
datapagemap_t pagemap; /* bitmap of pages updated since previous backup */ datapagemap_t pagemap; /* bitmap of pages updated since previous backup */
bool pagemap_isabsent; /* Used to mark files with unknown state of pagemap, bool pagemap_isabsent; /* Used to mark files with unknown state of pagemap,
* i.e. datafiles without _ptrack */ * i.e. datafiles without _ptrack */
/* state during bakup */
bool backuped; /* is file already completely copied into destination backup? */
} pgFile; } pgFile;
/* Special values of datapagemap_t bitmapsize */ /* Special values of datapagemap_t bitmapsize */
@ -555,8 +558,7 @@ extern pgBackup *catalog_get_last_data_backup(parray *backup_list,
TimeLineID tli); TimeLineID tli);
extern void pgBackupWriteControl(FILE *out, pgBackup *backup); extern void pgBackupWriteControl(FILE *out, pgBackup *backup);
extern void write_backup_filelist(pgBackup *backup, parray *files, extern void write_backup_filelist(pgBackup *backup, parray *files,
const char *root, const char *external_prefix, const char *root, parray *external_list);
parray *external_list);
extern void pgBackupGetPath(const pgBackup *backup, char *path, size_t len, extern void pgBackupGetPath(const pgBackup *backup, char *path, size_t len,
const char *subdir); const char *subdir);