MCPcopy Create free account
hub / github.com/apecloud/myduckserver / ExecuteRestore

Function ExecuteRestore

pgserver/restore_handler.go:110–123  ·  view source on GitHub ↗

ExecuteRestore downloads the specified file from the remote storage and restores it to the specified local directory. Note that this should only be called at startup, as this function does not attach the restored database to the catalog.

(dbName, localDir, localFile, remoteUri, endpoint, accessKeyId, secretAccessKey string)

Source from the content-addressed store, hash-verified

108// ExecuteRestore downloads the specified file from the remote storage and restores it to the specified local directory.
109// Note that this should only be called at startup, as this function does not attach the restored database to the catalog.
110func ExecuteRestore(dbName, localDir, localFile, remoteUri, endpoint, accessKeyId, secretAccessKey string) (string, error) {
111 storageConfig, remotePath, err := storage.ConstructStorageConfig(remoteUri, endpoint, accessKeyId, secretAccessKey)
112 if err != nil {
113 return "", fmt.Errorf("failed to construct storage configuration for restore: %w", err)
114 }
115
116 config := NewRestoreConfig(dbName, remotePath, storageConfig)
117
118 msg, err := config.StorageConfig.DownloadFile(config.RemoteFile, localDir, localFile)
119 if err != nil {
120 return "", fmt.Errorf("failed to download file: %w", err)
121 }
122 return msg, nil
123}

Callers 1

executeRestoreIfNeededFunction · 0.92

Calls 3

ConstructStorageConfigFunction · 0.92
NewRestoreConfigFunction · 0.85
DownloadFileMethod · 0.45

Tested by

no test coverage detected