MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / Start

Method Start

pkg/management/postgres/backup.go:96–134  ·  view source on GitHub ↗

Start initiates a backup for this instance using barman-cloud-backup

(ctx context.Context)

Source from the content-addressed store, hash-verified

94// Start initiates a backup for this instance using
95// barman-cloud-backup
96func (b *BackupCommand) Start(ctx context.Context) error {
97 contextLogger := log.FromContext(ctx)
98
99 b.setupBackupStatus()
100
101 err := PatchBackupStatusAndRetry(ctx, b.Client, b.Backup)
102 if err != nil {
103 return fmt.Errorf("can't set backup as running: %v", err)
104 }
105
106 if err := ensureWalArchiveIsWorking(b.Instance); err != nil {
107 contextLogger.Warning("WAL archiving is not working", "err", err)
108 b.Backup.GetStatus().Phase = apiv1.BackupPhaseWalArchivingFailing
109 return PatchBackupStatusAndRetry(ctx, b.Client, b.Backup)
110 }
111
112 if b.Backup.GetStatus().Phase != apiv1.BackupPhaseRunning {
113 b.Backup.GetStatus().Phase = apiv1.BackupPhaseRunning
114 err := PatchBackupStatusAndRetry(ctx, b.Client, b.Backup)
115 if err != nil {
116 contextLogger.Error(err, "can't set backup as WAL archiving failing")
117 }
118 }
119
120 b.Env, err = barmanCredentials.EnvSetBackupCloudCredentials(
121 ctx,
122 b.Client,
123 b.Cluster.Namespace,
124 b.Cluster.Spec.Backup.BarmanObjectStore,
125 b.Env)
126 if err != nil {
127 return fmt.Errorf("cannot recover backup credentials: %w", err)
128 }
129
130 // Run the actual backup process
131 go b.run(ctx)
132
133 return nil
134}
135
136func (b *BackupCommand) retryWithRefreshedCluster(
137 ctx context.Context,

Callers

nothing calls this directly

Calls 7

setupBackupStatusMethod · 0.95
runMethod · 0.95
WarningMethod · 0.80
GetStatusMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected