Start initiates a backup for this instance using barman-cloud-backup
(ctx context.Context)
| 94 | // Start initiates a backup for this instance using |
| 95 | // barman-cloud-backup |
| 96 | func (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 | |
| 136 | func (b *BackupCommand) retryWithRefreshedCluster( |
| 137 | ctx context.Context, |
nothing calls this directly
no test coverage detected