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

Commit0309dd7

Browse files
committed
minor bugfix: initialize backup.control before libpq connection, so errors are logged and failed backup gain ERROR status
1 parentcbef806 commit0309dd7

File tree

1 file changed

+36
-33
lines changed

1 file changed

+36
-33
lines changed

‎src/backup.c

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -661,28 +661,57 @@ do_backup(time_t start_time, bool no_validate)
661661
elog(ERROR,"required parameter not specified: PGDATA "
662662
"(-D, --pgdata)");
663663

664+
/* Update backup status and other metainfo. */
665+
current.status=BACKUP_STATUS_RUNNING;
666+
current.start_time=start_time;
667+
StrNCpy(current.program_version,PROGRAM_VERSION,
668+
sizeof(current.program_version));
669+
664670
current.compress_alg=instance_config.compress_alg;
665671
current.compress_level=instance_config.compress_level;
666672

673+
/* Save list of external directories */
674+
if (instance_config.external_dir_str&&
675+
pg_strcasecmp(instance_config.external_dir_str,"none")!=0)
676+
{
677+
current.external_dir_str=instance_config.external_dir_str;
678+
}
679+
680+
elog(INFO,"Backup start, pg_probackup version: %s, instance: %s, backup ID: %s, backup mode: %s, "
681+
"wal-method: %s, remote: %s, compress-algorithm: %s, compress-level: %i",
682+
PROGRAM_VERSION,instance_name,base36enc(start_time),pgBackupGetBackupMode(&current),
683+
current.stream ?"STREAM" :"ARCHIVE",IsSshProtocol() ?"true" :"false",
684+
deparse_compress_alg(current.compress_alg),current.compress_level);
685+
686+
/* Create backup directory and BACKUP_CONTROL_FILE */
687+
if (pgBackupCreateDir(&current))
688+
elog(ERROR,"Cannot create backup directory");
689+
if (!lock_backup(&current))
690+
elog(ERROR,"Cannot lock backup %s directory",
691+
base36enc(current.start_time));
692+
write_backup(&current);
693+
694+
/* set the error processing function for the backup process */
695+
pgut_atexit_push(backup_cleanup,NULL);
696+
697+
elog(LOG,"Backup destination is initialized");
698+
667699
/*
668700
* setup backup_conn, do some compatibility checks and
669701
* fill basic info about instance
670702
*/
671703
backup_conn=pgdata_basic_setup(instance_config.conn_opt,&nodeInfo);
704+
705+
if (current.from_replica)
706+
elog(INFO,"Backup %s is going to be taken from standby",base36enc(start_time));
707+
672708
/*
673709
* Ensure that backup directory was initialized for the same PostgreSQL
674710
* instance we opened connection to. And that target backup database PGDATA
675711
* belogns to the same instance.
676712
*/
677713
check_system_identifiers(backup_conn,instance_config.pgdata);
678714

679-
elog(INFO,"Backup start, pg_probackup version: %s, instance: %s, backup ID: %s, backup mode: %s, "
680-
"wal-method: %s, remote: %s, replica: %s, compress-algorithm: %s, compress-level: %i",
681-
PROGRAM_VERSION,instance_name,base36enc(start_time),pgBackupGetBackupMode(&current),
682-
current.stream ?"STREAM" :"ARCHIVE",IsSshProtocol() ?"true" :"false",
683-
current.from_replica ?"true" :"false",deparse_compress_alg(current.compress_alg),
684-
current.compress_level);
685-
686715
/* below perform checks specific for backup command */
687716
#ifPG_VERSION_NUM >=110000
688717
if (!RetrieveWalSegSize(backup_conn))
@@ -711,32 +740,6 @@ do_backup(time_t start_time, bool no_validate)
711740
if (instance_config.master_conn_opt.pghost==NULL)
712741
elog(ERROR,"Options for connection to master must be provided to perform backup from replica");
713742

714-
/* Start backup. Update backup status. */
715-
current.status=BACKUP_STATUS_RUNNING;
716-
current.start_time=start_time;
717-
StrNCpy(current.program_version,PROGRAM_VERSION,
718-
sizeof(current.program_version));
719-
720-
/* Save list of external directories */
721-
if (instance_config.external_dir_str&&
722-
pg_strcasecmp(instance_config.external_dir_str,"none")!=0)
723-
{
724-
current.external_dir_str=instance_config.external_dir_str;
725-
}
726-
727-
/* Create backup directory and BACKUP_CONTROL_FILE */
728-
if (pgBackupCreateDir(&current))
729-
elog(ERROR,"Cannot create backup directory");
730-
if (!lock_backup(&current))
731-
elog(ERROR,"Cannot lock backup %s directory",
732-
base36enc(current.start_time));
733-
write_backup(&current);
734-
735-
elog(LOG,"Backup destination is initialized");
736-
737-
/* set the error processing function for the backup process */
738-
pgut_atexit_push(backup_cleanup,NULL);
739-
740743
/* backup data */
741744
do_backup_instance(backup_conn,&nodeInfo);
742745
pgut_atexit_pop(backup_cleanup,NULL);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp