feat: log the downloaded backup catalog before restore (#323)

Closes: #319

Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
This commit is contained in:
Leonardo Cecchi 2025-05-08 10:51:35 +02:00 committed by GitHub
parent 087623f3f2
commit 9db184f5d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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"
@ -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
@ -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
}