MCPcopy Index your code
hub / github.com/ddev/ddev / getDatabaseBackups

Method getDatabaseBackups

pkg/ddevapp/provider.go:334–376  ·  view source on GitHub ↗

getDatabaseBackups retrieves database using `generic backup database`, then describe until it appears, then download it.

()

Source from the content-addressed store, hash-verified

332// getDatabaseBackups retrieves database using `generic backup database`, then
333// describe until it appears, then download it.
334func (p *Provider) getDatabaseBackups() ([]string, error) {
335 err := os.RemoveAll(p.getDownloadDir())
336 if err != nil {
337 return nil, err
338 }
339 // Make sure the deletion is synced before we recreate
340 err = p.app.MutagenSyncFlush()
341 if err != nil {
342 return nil, err
343 }
344 err = os.Mkdir(p.getDownloadDir(), 0755)
345 if err != nil {
346 return nil, err
347 }
348
349 if p.DBPullCommand.Command == "" {
350 util.Warning("No db_pull_command provided, so skipping database pull")
351 return nil, nil
352 }
353
354 s := p.DBPullCommand.Service
355 if s == "" {
356 s = "web"
357 }
358 err = p.app.MutagenSyncFlush()
359 if err != nil {
360 return nil, err
361 }
362 err = p.app.ExecOnHostOrService(s, p.injectedEnvironment()+"; "+p.DBPullCommand.Command)
363 if err != nil {
364 return nil, fmt.Errorf("failed to exec %s on %s: %v", p.DBPullCommand.Command, s, err)
365 }
366 err = p.app.MutagenSyncFlush()
367 if err != nil {
368 return nil, err
369 }
370
371 sqlTarballs, err := fileutil.ListFilesInDirFullPath(p.getDownloadDir(), true)
372 if err != nil || sqlTarballs == nil {
373 return nil, fmt.Errorf("failed to find downloaded files in %s: %v", p.getDownloadDir(), err)
374 }
375 return sqlTarballs, nil
376}
377
378// importDatabaseBackup will import a slice of downloaded databases
379// If a custom importer is provided, that will be used, otherwise

Callers 1

GetBackupMethod · 0.95

Calls 7

getDownloadDirMethod · 0.95
injectedEnvironmentMethod · 0.95
WarningFunction · 0.92
ListFilesInDirFullPathFunction · 0.92
MutagenSyncFlushMethod · 0.80
ExecOnHostOrServiceMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected