Skip to content

Commit

Permalink
Allow target to be left out
Browse files Browse the repository at this point in the history
  • Loading branch information
davissp14 committed Jul 5, 2024
1 parent 6e3aa73 commit 0f58fd5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 4 additions & 5 deletions internal/flypg/barman_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ func NewBarmanRestore(configURL string) (*BarmanRestore, error) {
restore.recoveryTargetAction = "promote"
}

if restore.recoveryTargetName == "" && restore.recoveryTargetTime == "" && restore.recoveryTarget == "" {
return nil, fmt.Errorf("no restore target specified")
}

return restore, nil
}

Expand Down Expand Up @@ -171,7 +167,10 @@ func (b *BarmanRestore) restoreFromBackup(ctx context.Context) error {
return fmt.Errorf("failed to resolve backup target by id: %s", err)
}
default:
return fmt.Errorf("restore target not specified")
backupID, err = b.resolveBackupFromTime(backups, time.Now().Format(time.RFC3339))
if err != nil {
return fmt.Errorf("failed to resolve backup target by time: %s", err)
}
}

if backupID == "" {
Expand Down
2 changes: 0 additions & 2 deletions internal/flypg/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ func (c *PGConfig) setRecoveryTargetConfig(configURL string) error {
c.internalConfig["recovery_target_name"] = fmt.Sprintf("barman_%s", barmanRestore.recoveryTargetName)
case barmanRestore.recoveryTargetTime != "":
c.internalConfig["recovery_target_time"] = fmt.Sprintf("'%s'", barmanRestore.recoveryTargetTime)
default:
return fmt.Errorf("recovery target name or time must be specified")
}

return nil
Expand Down

0 comments on commit 0f58fd5

Please sign in to comment.