mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-03-06 16:16:33 +02:00
use data_bytes field instead of introducing new one
This commit is contained in:
parent
096a12b9bc
commit
6f2d3f5cc5
23
src/backup.c
23
src/backup.c
@ -182,9 +182,6 @@ do_backup_instance(PGconn *backup_conn)
|
||||
check_external_for_tablespaces(external_dirs, backup_conn);
|
||||
}
|
||||
|
||||
/* Initialize size summary */
|
||||
current.data_bytes = 0;
|
||||
|
||||
/* Obtain current timeline */
|
||||
current.tli = get_current_timeline(false);
|
||||
|
||||
@ -432,6 +429,7 @@ do_backup_instance(PGconn *backup_conn)
|
||||
}
|
||||
else
|
||||
join_path_components(dirpath, database_path, dir_name);
|
||||
file->backuped = true;
|
||||
fio_mkdir(dirpath, DIR_PERMISSION, FIO_BACKUP_HOST);
|
||||
}
|
||||
|
||||
@ -581,19 +579,6 @@ do_backup_instance(PGconn *backup_conn)
|
||||
if (external_dirs)
|
||||
free_dir_list(external_dirs);
|
||||
|
||||
/* Compute summary of size of regular files in the backup */
|
||||
for (i = 0; i < parray_num(backup_files_list); i++)
|
||||
{
|
||||
pgFile *file = (pgFile *) parray_get(backup_files_list, i);
|
||||
|
||||
if (S_ISDIR(file->mode))
|
||||
current.data_bytes += 4096;
|
||||
|
||||
/* Count the amount of the data actually copied */
|
||||
if (S_ISREG(file->mode))
|
||||
current.data_bytes += file->write_size;
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
if (backup_list)
|
||||
{
|
||||
@ -1805,11 +1790,12 @@ pg_stop_backup(pgBackup *backup, PGconn *pg_startbackup_conn)
|
||||
*/
|
||||
if (backup_files_list)
|
||||
{
|
||||
file = pgFileNew(backup_label, backup_label, true, 0,
|
||||
file = pgFileNew(backup_label, PG_BACKUP_LABEL_FILE, true, 0,
|
||||
FIO_BACKUP_HOST);
|
||||
file->crc = pgFileGetCRC(file->path, true, false,
|
||||
&file->read_size, FIO_BACKUP_HOST);
|
||||
file->write_size = file->read_size;
|
||||
file->backuped = true;
|
||||
free(file->path);
|
||||
file->path = strdup(PG_BACKUP_LABEL_FILE);
|
||||
parray_append(backup_files_list, file);
|
||||
@ -1851,13 +1837,14 @@ pg_stop_backup(pgBackup *backup, PGconn *pg_startbackup_conn)
|
||||
|
||||
if (backup_files_list)
|
||||
{
|
||||
file = pgFileNew(tablespace_map, tablespace_map, true, 0,
|
||||
file = pgFileNew(tablespace_map, PG_TABLESPACE_MAP_FILE, true, 0,
|
||||
FIO_BACKUP_HOST);
|
||||
if (S_ISREG(file->mode))
|
||||
{
|
||||
file->crc = pgFileGetCRC(file->path, true, false,
|
||||
&file->read_size, FIO_BACKUP_HOST);
|
||||
file->write_size = file->read_size;
|
||||
file->backuped = true;
|
||||
}
|
||||
free(file->path);
|
||||
file->path = strdup(PG_TABLESPACE_MAP_FILE);
|
||||
|
@ -108,7 +108,7 @@ write_backup_control_on_the_fly(pgBackup *backup)
|
||||
}
|
||||
|
||||
tmp->status = backup->status;
|
||||
tmp->size_on_disk = backup->size_on_disk;
|
||||
tmp->data_bytes = backup->data_bytes;
|
||||
backup->duration = difftime(time(NULL), backup->start_time);
|
||||
tmp->duration = backup->duration;
|
||||
write_backup(tmp);
|
||||
@ -611,7 +611,6 @@ pgBackupWriteControl(FILE *out, pgBackup *backup)
|
||||
if (backup->external_dir_str)
|
||||
fio_fprintf(out, "external-dirs = '%s'\n", backup->external_dir_str);
|
||||
|
||||
fio_fprintf(out, "size-on-disk = " INT64_FORMAT "\n", backup->size_on_disk);
|
||||
fio_fprintf(out, "duration = " INT64_FORMAT "\n", backup->duration);
|
||||
}
|
||||
|
||||
@ -668,7 +667,7 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
|
||||
#define BUFFERSZ BLCKSZ*500
|
||||
char buf[BUFFERSZ];
|
||||
size_t write_len = 0;
|
||||
int64 backup_size_on_disk = BYTES_INVALID;
|
||||
int64 backup_size_on_disk = 0;
|
||||
|
||||
pgBackupGetPath(backup, path, lengthof(path), DATABASE_FILE_LIST);
|
||||
snprintf(path_temp, sizeof(path_temp), "%s.tmp", path);
|
||||
@ -687,10 +686,20 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
|
||||
int len = 0;
|
||||
|
||||
i++;
|
||||
if (!file->backuped)
|
||||
continue;
|
||||
|
||||
backup_size_on_disk += file->write_size;
|
||||
if (!file->backuped)
|
||||
{
|
||||
elog(WARNING, "file not backuped %s", file->rel_path);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (S_ISDIR(file->mode))
|
||||
backup_size_on_disk += 4096;
|
||||
|
||||
/* Count the amount of the data actually copied */
|
||||
if (S_ISREG(file->mode))
|
||||
backup_size_on_disk += file->write_size;
|
||||
|
||||
if (file->external_dir_num && external_list)
|
||||
{
|
||||
path = GetRelativePath(path, parray_get(external_list,
|
||||
@ -767,7 +776,8 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
|
||||
path_temp, path, strerror(errno_temp));
|
||||
}
|
||||
|
||||
backup->size_on_disk = backup_size_on_disk;
|
||||
/* use extra variable to avoid reset of previous data_bytes value in case of error */
|
||||
backup->data_bytes = backup_size_on_disk;
|
||||
write_backup_control_on_the_fly(backup);
|
||||
}
|
||||
|
||||
@ -816,7 +826,6 @@ readBackupControlFile(const char *path)
|
||||
{'b', 0, "from-replica", &backup->from_replica, SOURCE_FILE_STRICT},
|
||||
{'s', 0, "primary-conninfo", &backup->primary_conninfo, SOURCE_FILE_STRICT},
|
||||
{'s', 0, "external-dirs", &backup->external_dir_str, SOURCE_FILE_STRICT},
|
||||
{'I', 0, "size-on-disk", &backup->size_on_disk, SOURCE_FILE_STRICT},
|
||||
{'I', 0, "duration", &backup->duration, SOURCE_FILE_STRICT},
|
||||
{0}
|
||||
};
|
||||
@ -1050,7 +1059,6 @@ pgBackupInit(pgBackup *backup)
|
||||
backup->server_version[0] = '\0';
|
||||
backup->external_dir_str = NULL;
|
||||
|
||||
backup->size_on_disk = BYTES_INVALID;
|
||||
backup->duration = (time_t) 0;
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,6 @@ struct pgBackup
|
||||
char *external_dir_str; /* List of external directories,
|
||||
* separated by ':' */
|
||||
|
||||
int64 size_on_disk; /* updated based on backup_content.control */
|
||||
int64 duration; /* TODO write better comment. time(NULL)-start_time */
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user