Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PBCKP-170#515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dlepikhova merged 6 commits intoREL_2_5fromPBCKP-170
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletionssrc/backup.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -695,7 +695,7 @@ pgdata_basic_setup(ConnectionOptions conn_opt, PGNodeInfo *nodeInfo)
*/
int
do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
bool no_validate, bool no_sync, bool backup_logs)
bool no_validate, bool no_sync, bool backup_logs, time_t start_time)
{
PGconn*backup_conn = NULL;
PGNodeInfonodeInfo;
Expand All@@ -710,7 +710,7 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
current.external_dir_str = instance_config.external_dir_str;

/* Create backup directory and BACKUP_CONTROL_FILE */
pgBackupCreateDir(&current, instanceState->instance_backup_subdir_path);
pgBackupCreateDir(&current, instanceState, start_time);

if (!instance_config.pgdata)
elog(ERROR, "required parameter not specified: PGDATA "
Expand Down
35 changes: 27 additions & 8 deletionssrc/catalog.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ static pgBackup* get_closest_backup(timelineInfo *tlinfo);
static pgBackup* get_oldest_backup(timelineInfo *tlinfo);
static const char *backupModes[] = {"", "PAGE", "PTRACK", "DELTA", "FULL"};
static pgBackup *readBackupControlFile(const char *path);
statictime_t create_backup_dir(pgBackup *backup, const char *backup_instance_path);
staticvoid create_backup_dir(pgBackup *backup, const char *backup_instance_path);

static bool backup_lock_exit_hook_registered = false;
static parray *locks = NULL;
Expand DownExpand Up@@ -1420,10 +1420,12 @@ get_multi_timeline_parent(parray *backup_list, parray *tli_list,
*/

void
pgBackupCreateDir(pgBackup *backup,const char *backup_instance_path)
pgBackupCreateDir(pgBackup *backup,InstanceState *instanceState, time_t start_time)
{
inti;
parray *subdirs = parray_new();
parray * backups;
pgBackup *target_backup;

parray_append(subdirs, pg_strdup(DATABASE_DIR));

Expand All@@ -1444,7 +1446,26 @@ pgBackupCreateDir(pgBackup *backup, const char *backup_instance_path)
free_dir_list(external_list);
}

backup->backup_id = create_backup_dir(backup, backup_instance_path);
/* Get list of all backups*/
backups = catalog_get_backup_list(instanceState, INVALID_BACKUP_ID);
if (parray_num(backups) > 0)
{
target_backup = (pgBackup *) parray_get(backups, 0);
if (start_time > target_backup->backup_id)
{
backup->backup_id = start_time;
create_backup_dir(backup, instanceState->instance_backup_subdir_path);
}
else
{
elog(ERROR, "Cannot create directory for older backup");
}
}
else
{
backup->backup_id = start_time;
create_backup_dir(backup, instanceState->instance_backup_subdir_path);
}

if (backup->backup_id == 0)
elog(ERROR, "Cannot create backup directory: %s", strerror(errno));
Expand All@@ -1471,7 +1492,7 @@ pgBackupCreateDir(pgBackup *backup, const char *backup_instance_path)
* Create root directory for backup,
* update pgBackup.root_dir if directory creation was a success
*/
time_t
void
create_backup_dir(pgBackup *backup, const char *backup_instance_path)
{
int attempts = 10;
Expand All@@ -1480,17 +1501,16 @@ create_backup_dir(pgBackup *backup, const char *backup_instance_path)
{
int rc;
char path[MAXPGPATH];
time_t backup_id = time(NULL);

join_path_components(path, backup_instance_path, base36enc(backup_id));
join_path_components(path, backup_instance_path, base36enc(backup->backup_id));

/* TODO: add wrapper for remote mode */
rc = dir_create_dir(path, DIR_PERMISSION, true);

if (rc == 0)
{
backup->root_dir = pgut_strdup(path);
return backup_id;
return;
}
else
{
Expand All@@ -1499,7 +1519,6 @@ create_backup_dir(pgBackup *backup, const char *backup_instance_path)
}
}

return 0;
}

/*
Expand Down
11 changes: 10 additions & 1 deletionsrc/pg_probackup.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,6 +78,7 @@ pid_t my_pid = 0;
__thread int my_thread_num = 1;
boolprogress = false;
boolno_sync = false;
time_tstart_time = 0;
#if PG_VERSION_NUM >= 100000
char *replication_slot = NULL;
booltemp_slot = false;
Expand DownExpand Up@@ -200,6 +201,7 @@ static ConfigOption cmd_options[] =
{ 's', 'i', "backup-id",&backup_id_string,SOURCE_CMD_STRICT },
{ 'b', 133, "no-sync",&no_sync,SOURCE_CMD_STRICT },
{ 'b', 134, "no-color",&no_color,SOURCE_CMD_STRICT },
{ 'U', 241, "start-time",&start_time,SOURCE_CMD_STRICT },
/* backup options */
{ 'b', 180, "backup-pg-log",&backup_logs,SOURCE_CMD_STRICT },
{ 'f', 'b', "backup-mode",opt_backup_mode,SOURCE_CMD_STRICT },
Expand DownExpand Up@@ -940,14 +942,21 @@ main(int argc, char *argv[])
case BACKUP_CMD:
{
current.stream = stream_wal;
if (start_time == 0)
start_time = current_time;
else
elog(WARNING, "Please do not use the --start-time option to start backup. "
"This is a service option required to work with other extensions. "
"We do not guarantee future support for this flag.");


/* sanity */
if (current.backup_mode == BACKUP_MODE_INVALID)
elog(ERROR, "required parameter not specified: BACKUP_MODE "
"(-b, --backup-mode)");

return do_backup(instanceState, set_backup_params,
no_validate, no_sync, backup_logs);
no_validate, no_sync, backup_logs, start_time);
}
case CATCHUP_CMD:
return do_catchup(catchup_source_pgdata, catchup_destination_pgdata, num_threads, !no_sync,
Expand Down
4 changes: 2 additions & 2 deletionssrc/pg_probackup.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -840,7 +840,7 @@ extern char** commands_args;

/* in backup.c */
extern int do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
bool no_validate, bool no_sync, bool backup_logs);
bool no_validate, bool no_sync, bool backup_logs, time_t start_time);
extern void do_checkdb(bool need_amcheck, ConnectionOptions conn_opt,
char *pgdata);
extern BackupMode parse_backup_mode(const char *value);
Expand DownExpand Up@@ -981,7 +981,7 @@ extern void write_backup_filelist(pgBackup *backup, parray *files,
const char *root, parray *external_list, bool sync);


extern void pgBackupCreateDir(pgBackup *backup,const char *backup_instance_path);
extern void pgBackupCreateDir(pgBackup *backup,InstanceState *instanceState, time_t start_time);
extern void pgNodeInit(PGNodeInfo *node);
extern void pgBackupInit(pgBackup *backup);
extern void pgBackupFree(void *backup);
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp