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

Function executeRestoreIfNeeded

main.go:220–255  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

218}
219
220func executeRestoreIfNeeded() {
221 // If none of the restore parameters are set, return early.
222 if restoreFile == "" && restoreEndpoint == "" && restoreAccessKeyId == "" && restoreSecretAccessKey == "" {
223 return
224 }
225
226 // Map of required parameters to their names for validation.
227 required := map[string]string{
228 restoreFile: "restore file",
229 restoreEndpoint: "restore endpoint",
230 restoreAccessKeyId: "restore access key ID",
231 restoreSecretAccessKey: "restore secret access key",
232 }
233
234 // Validate that all required parameters are set.
235 for val, name := range required {
236 if val == "" {
237 logrus.Fatalf("The %s is required.", name)
238 }
239 }
240
241 msg, err := pgserver.ExecuteRestore(
242 defaultDb,
243 dataDirectory,
244 defaultDb+".db",
245 restoreFile,
246 restoreEndpoint,
247 restoreAccessKeyId,
248 restoreSecretAccessKey,
249 )
250 if err != nil {
251 logrus.WithError(err).Fatalln("Failed to execute restore:", msg)
252 }
253
254 logrus.Infoln("Restore completed successfully:", msg)
255}

Callers 1

mainFunction · 0.85

Calls 1

ExecuteRestoreFunction · 0.92

Tested by

no test coverage detected