Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions internal/cnpgi/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"path"
"time"

"github.com/cloudnative-pg/barman-cloud/pkg/api"
barmanArchiver "github.com/cloudnative-pg/barman-cloud/pkg/archiver"
Expand Down Expand Up @@ -358,10 +359,12 @@ func loadBackupObjectFromExternalCluster(
return nil, nil, err
}

contextLogger.Info("Downloading backup catalog")
backupCatalog, err := barmanCommand.GetBackupList(ctx, recoveryObjectStore, serverName, env)
if err != nil {
return nil, nil, err
}
contextLogger.Info("Downloaded backup catalog", "backupCatalog", shortenedCatalog(backupCatalog))

// We are now choosing the right backup to restore
var targetBackup *barmanCatalog.BarmanBackup
Expand Down Expand Up @@ -408,3 +411,34 @@ func loadBackupObjectFromExternalCluster(
},
}, env, nil
}

// ShortBackupCatalogEntry is used when logging the downloaded backup
// catalog and contains only the fields used for debugging
type ShortBackupCatalogEntry struct {
// BackupID is the backup ID
BackupID string `json:"backupID"`

// StartTime is the backup time
StartTime time.Time `json:"startTime"`

// EndTime is the end time
EndTime time.Time `json:"endTime"`
}

// shortenedCatalog creates a structure containing the debug information
// of a backup catalog.
func shortenedCatalog(catalog *barmanCatalog.Catalog) []ShortBackupCatalogEntry {
if catalog == nil {
return nil
}

result := make([]ShortBackupCatalogEntry, len(catalog.List))

for i, v := range catalog.List {
result[i].BackupID = v.BackupName
result[i].StartTime = v.BeginTime
result[i].EndTime = v.EndTime
}

return result
}