mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-11 21:23:12 +01:00
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:
parent
087623f3f2
commit
9db184f5d4
@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/cloudnative-pg/barman-cloud/pkg/api"
|
"github.com/cloudnative-pg/barman-cloud/pkg/api"
|
||||||
barmanArchiver "github.com/cloudnative-pg/barman-cloud/pkg/archiver"
|
barmanArchiver "github.com/cloudnative-pg/barman-cloud/pkg/archiver"
|
||||||
@ -358,10 +359,12 @@ func loadBackupObjectFromExternalCluster(
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contextLogger.Info("Downloading backup catalog")
|
||||||
backupCatalog, err := barmanCommand.GetBackupList(ctx, recoveryObjectStore, serverName, env)
|
backupCatalog, err := barmanCommand.GetBackupList(ctx, recoveryObjectStore, serverName, env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
contextLogger.Info("Downloaded backup catalog", "backupCatalog", shortenedCatalog(backupCatalog))
|
||||||
|
|
||||||
// We are now choosing the right backup to restore
|
// We are now choosing the right backup to restore
|
||||||
var targetBackup *barmanCatalog.BarmanBackup
|
var targetBackup *barmanCatalog.BarmanBackup
|
||||||
@ -408,3 +411,34 @@ func loadBackupObjectFromExternalCluster(
|
|||||||
},
|
},
|
||||||
}, env, nil
|
}, 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
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user