@@ -661,28 +661,57 @@ do_backup(time_t start_time, bool no_validate)
661
661
elog (ERROR ,"required parameter not specified: PGDATA "
662
662
"(-D, --pgdata)" );
663
663
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
+
664
670
current .compress_alg = instance_config .compress_alg ;
665
671
current .compress_level = instance_config .compress_level ;
666
672
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
+
667
699
/*
668
700
* setup backup_conn, do some compatibility checks and
669
701
* fill basic info about instance
670
702
*/
671
703
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
+
672
708
/*
673
709
* Ensure that backup directory was initialized for the same PostgreSQL
674
710
* instance we opened connection to. And that target backup database PGDATA
675
711
* belogns to the same instance.
676
712
*/
677
713
check_system_identifiers (backup_conn ,instance_config .pgdata );
678
714
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
-
686
715
/* below perform checks specific for backup command */
687
716
#if PG_VERSION_NUM >=110000
688
717
if (!RetrieveWalSegSize (backup_conn ))
@@ -711,32 +740,6 @@ do_backup(time_t start_time, bool no_validate)
711
740
if (instance_config .master_conn_opt .pghost == NULL )
712
741
elog (ERROR ,"Options for connection to master must be provided to perform backup from replica" );
713
742
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
-
740
743
/* backup data */
741
744
do_backup_instance (backup_conn ,& nodeInfo );
742
745
pgut_atexit_pop (backup_cleanup ,NULL );