MCPcopy
hub / github.com/pocketbase/pocketbase / backupCreate

Function backupCreate

apis/backup_create.go:12–38  ·  view source on GitHub ↗
(e *core.RequestEvent)

Source from the content-addressed store, hash-verified

10)
11
12func backupCreate(e *core.RequestEvent) error {
13 if e.App.Store().Has(core.StoreKeyActiveBackup) {
14 return e.BadRequestError("Try again later - another backup/restore process has already been started", nil)
15 }
16
17 form := new(backupCreateForm)
18 form.app = e.App
19
20 err := e.BindBody(form)
21 if err != nil {
22 return e.BadRequestError("An error occurred while loading the submitted data.", err)
23 }
24
25 err = form.validate()
26 if err != nil {
27 return e.BadRequestError("An error occurred while validating the submitted data.", err)
28 }
29
30 err = e.App.CreateBackup(context.Background(), form.Name)
31 if err != nil {
32 return e.BadRequestError("Failed to create backup.", err)
33 }
34
35 // we don't retrieve the generated backup file because it may not be
36 // available yet due to the eventually consistent nature of some S3 providers
37 return e.NoContent(http.StatusNoContent)
38}
39
40// -------------------------------------------------------------------
41

Callers

nothing calls this directly

Calls 7

BadRequestErrorMethod · 0.80
BindBodyMethod · 0.80
NoContentMethod · 0.80
StoreMethod · 0.65
validateMethod · 0.65
CreateBackupMethod · 0.65
HasMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…