initdbSyncOnly Run initdb with --sync-only option after a database import
(ctx context.Context)
| 624 | |
| 625 | // initdbSyncOnly Run initdb with --sync-only option after a database import |
| 626 | func (info InitInfo) initdbSyncOnly(ctx context.Context) error { |
| 627 | contextLogger := log.FromContext(ctx) |
| 628 | |
| 629 | // Invoke initdb to generate a data directory |
| 630 | options := []string{ |
| 631 | "-D", |
| 632 | info.PgData, |
| 633 | "--sync-only", |
| 634 | } |
| 635 | contextLogger.Info("Running initdb --sync-only", "pgdata", info.PgData) |
| 636 | initdbCmd := exec.Command(constants.InitdbName, options...) // #nosec |
| 637 | if err := execlog.RunBuffering(initdbCmd, constants.InitdbName); err != nil { |
| 638 | return fmt.Errorf("error while running initdb --sync-only: %w", err) |
| 639 | } |
| 640 | return nil |
| 641 | } |