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

View File

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

View File

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

View File

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