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)
| 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. |
| 36 | func (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. |
nothing calls this directly
no test coverage detected