MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / BackupDB

Method BackupDB

api/admin.go:36–48  ·  view source on GitHub ↗

BackupDB creates a backup of the database and stores it on disk. It initializes a BackupManager and performs the backup operation. If any error occurs during backup creation, it responds with an error message. Parameters: - c: The Gin context containing the request and response. Responses: - 400 B

(c *gin.Context)

Source from the content-addressed store, hash-verified

34// - 400 Bad Request: If there's an error in creating the backup or initializing the BackupManager.
35// - 200 OK: If the backup is successfully created and stored on disk.
36func (a Api) BackupDB(c *gin.Context) {
37 backupManager, err := backups.NewBackupManager()
38 if err != nil {
39 c.JSON(http.StatusBadRequest, gin.H{"error": apierror.NewAPIError(apierror.ErrInternalServer, "error creating backup", err)})
40 return
41 }
42 _, err = backupManager.BackupToDisk(c.Request.Context())
43 if err != nil {
44 c.JSON(http.StatusBadRequest, gin.H{"error": apierror.NewAPIError(apierror.ErrInternalServer, "error creating backup", err)})
45 return
46 }
47 c.JSON(http.StatusOK, "backup successful")
48}
49
50// BackupDBS3 creates a backup of the database and stores it in S3.
51// It initializes a BackupManager and performs the backup operation to S3.

Callers

nothing calls this directly

Calls 2

BackupToDiskMethod · 0.95
NewAPIErrorFunction · 0.92

Tested by

no test coverage detected