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)
| 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. |
| 110 | func 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 | } |
no test coverage detected