@@ -504,7 +504,7 @@ func (p *Manager) SyncFromFollowedPGRewind(followedConnParams ConnParams, passwo
504
504
user := followedConnParams .Get ("user" )
505
505
pgpass .WriteString (fmt .Sprintf ("%s:%s:*:%s:%s\n " ,host ,port ,user ,password ))
506
506
507
- // Disablesyncronous replication . pg_rewind needs to create a
507
+ // Disablesynchronous commits . pg_rewind needs to create a
508
508
// temporary table on the master but if synchronous replication is
509
509
// enabled and there're no active standbys it will hang.
510
510
followedConnParams .Set ("options" ,"-c synchronous_commit=off" )
@@ -524,6 +524,8 @@ func (p *Manager) SyncFromFollowedPGRewind(followedConnParams ConnParams, passwo
524
524
}
525
525
526
526
func (p * Manager )SyncFromFollowed (followedConnParams ConnParams )error {
527
+ fcp := followedConnParams .Copy ()
528
+
527
529
// ioutil.Tempfile already creates files with 0600 permissions
528
530
pgpass ,err := ioutil .TempFile ("" ,"pgpass" )
529
531
if err != nil {
@@ -532,15 +534,24 @@ func (p *Manager) SyncFromFollowed(followedConnParams ConnParams) error {
532
534
defer os .Remove (pgpass .Name ())
533
535
defer pgpass .Close ()
534
536
535
- host := followedConnParams .Get ("host" )
536
- port := followedConnParams .Get ("port" )
537
- user := followedConnParams .Get ("user" )
538
- password := followedConnParams .Get ("password" )
537
+ host := fcp .Get ("host" )
538
+ port := fcp .Get ("port" )
539
+ user := fcp .Get ("user" )
540
+ password := fcp .Get ("password" )
539
541
pgpass .WriteString (fmt .Sprintf ("%s:%s:*:%s:%s\n " ,host ,port ,user ,password ))
540
542
543
+ // Remove password from the params passed to pg_basebackup
544
+ fcp .Del ("password" )
545
+
546
+ // Disable synchronous commits. pg_basebackup calls
547
+ // pg_start_backup()/pg_stop_backup() on the master but if synchronous
548
+ // replication is enabled and there're no active standbys they will hang.
549
+ fcp .Set ("options" ,"-c synchronous_commit=off" )
550
+ followedConnString := fcp .ConnString ()
551
+
541
552
log .Info ("running pg_basebackup" )
542
553
name := filepath .Join (p .pgBinPath ,"pg_basebackup" )
543
- cmd := exec .Command (name ,"-R" ,"-D" ,p .dataDir ,"--host=" + host , "--port=" + port , "-U" , user )
554
+ cmd := exec .Command (name ,"-R" ,"-D" ,p .dataDir ,"-d" , followedConnString )
544
555
cmd .Env = append (cmd .Env ,fmt .Sprintf ("PGPASSFILE=%s" ,pgpass .Name ()))
545
556
log .Debug ("execing cmd" ,zap .Object ("cmd" ,cmd ))
546
557
if out ,err := cmd .CombinedOutput ();err != nil {