> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camposcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# /v1/databases/{databaseId}/backups

> This endpoint starts a manual backup of a database.

> [!WARNING]
>
> This endpoint has a rate limit of 1 request per second.


## OpenAPI

````yaml POST /v1/databases/{databaseId}/backups
openapi: 3.1.0
info:
  title: CamposCloud API Documentation
  description: >-
    This documentation provides an overview of the CamposCloud API, including
    authentication, endpoints, and data structures. It is designed to help
    developers integrate with the CamposCloud platform effectively.
  version: 1.0.0
servers:
  - url: https://api.camposcloud.com
security:
  - bearerAuth: []
paths:
  /v1/databases/{databaseId}/backups:
    post:
      tags:
        - Databases
      description: >-
        Starts a manual backup. It runs in the background: the answer is the
        backup with `status: pending`; list the backups to follow it. The
        database keeps running meanwhile.


        A database holds up to 4 manual backups (failed ones do not count). A
        copy over 5 GB gzipped fails. The database must have the status `active`
        and its owner an active plan.


        A database may ask for up to 10 manual backups a day, deleted ones
        included.
      parameters:
        - name: databaseId
          in: path
          required: true
          description: ID of the database.
          schema:
            type: string
            pattern: ^[a-f0-9]{24}$
      responses:
        '202':
          description: The backup started.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DatabaseBackup'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            You are not allowed to back up the database, or its owner has no
            active plan.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: O dono deste banco não tem um plano ativo.
                code: PLAN_INACTIVE
        '404':
          description: Database (or backup) not found, or not yours.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Banco de dados não encontrado.
                code: DATABASE_NOT_FOUND
        '409':
          description: >-
            The database already has 4 manual backups, is not ready, or a backup
            or restore is in progress.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: >-
                  Este banco já tem 4 backups manuais. Apague um para fazer
                  outro.
                code: MANUAL_BACKUP_LIMIT
        '429':
          description: >-
            A rate limit was exceeded, or the database already made 10 manual
            backups today.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Este banco já fez 10 backups manuais hoje. Tente amanhã.
                code: MANUAL_BACKUP_DAILY_LIMIT
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    DatabaseBackup:
      type: object
      description: >-
        A copy of a database's data, made by the database engine itself
        (mysqldump, pg_dump, mongodump or Redis' RDB), gzipped, encrypted and
        kept off the server. For PostgreSQL, the backup holds the database
        created with it (`POSTGRES_DB`); other databases created inside the same
        instance are not included.
      properties:
        _id:
          type: string
          description: ID of the backup.
        databaseInstanceId:
          type: string
          description: ID of the database.
        type:
          type: string
          enum:
            - manual
            - automatic
          description: >-
            `manual` backups are made on request and kept until deleted (up to 4
            per database). `automatic` ones leave on their own.
        reason:
          type: string
          enum:
            - manual
            - daily
            - before-restore
          description: >-
            Why it exists: asked for, the daily one (the 7 newest are kept), or
            the copy taken right before a restore (the 2 newest are kept).
        status:
          type: string
          enum:
            - pending
            - running
            - done
            - failed
        engine:
          type: string
          enum:
            - mysql
            - postgresql
            - mongodb
            - redis
        sizeInBytes:
          type: integer
          nullable: true
          description: Size of the gzipped dump, which is what a download gives.
        sha256:
          type: string
          nullable: true
          description: SHA-256 of the gzipped dump.
        error:
          type: string
          nullable: true
          description: Why it failed, when `status` is `failed`.
        startedAt:
          type: string
          format: date-time
          nullable: true
        finishedAt:
          type: string
          format: date-time
          nullable: true
        restoredAt:
          type: string
          format: date-time
          nullable: true
          description: The last time it was restored into its database.
        restore:
          type: object
          nullable: true
          description: The last restore asked for from this backup.
          properties:
            status:
              type: string
              enum:
                - running
                - done
                - failed
            error:
              type: string
              nullable: true
            startedAt:
              type: string
              format: date-time
              nullable: true
            finishedAt:
              type: string
              format: date-time
              nullable: true
            errorCode:
              type: string
              nullable: true
              description: >-
                For example `RESTORE_SAFETY_FAILED`, `RESTORE_FAILED` or
                `RESTORE_START_FAILED` (the data was restored but the database
                did not start again).
        createdAt:
          type: string
          format: date-time
        errorCode:
          type: string
          nullable: true
          description: >-
            A stable code for `error`, such as `BACKUP_TOO_LARGE`,
            `DATABASE_NOT_RUNNING` or `BACKUP_TIMEOUT`.
        databaseName:
          type: string
          nullable: true
          description: >-
            The database's name when the backup was made (kept after the
            database is deleted).
    Error:
      type: object
      description: >-
        Every error returned by the API has this shape. `error` is a human
        readable message (in English or in Portuguese, depending on the
        endpoint). Many errors also carry `code`, a stable identifier to rely on
        in your code, and sometimes extra fields with details (for example
        `requestedMB` and `availableMB` with `PLAN_MEMORY_LIMIT`). Resources you
        have no relation to answer `404`, not `403`.
      required:
        - error
      properties:
        error:
          type: string
          description: Human readable description of the error.
          example: Application not found.
        code:
          type: string
          description: >-
            Stable, machine-readable identifier of the error. Present on many
            errors; compare against it instead of the message. Examples:
            `PLAN_MEMORY_LIMIT`, `APPLICATION_NOT_FOUND`, `DATABASE_NOT_FOUND`,
            `MAIN_FILE_INVALID`, `ENV_DUPLICATE_KEY`, `CUSTOM_DOMAIN_IN_USE`,
            `CUSTOM_DOMAIN_RESERVED`, `CUSTOM_DOMAIN_NOT_CLOUDFLARE`,
            `CUSTOM_DOMAIN_NO_PENDING`, `CUSTOM_DOMAIN_TXT_NOT_FOUND`.
          example: PLAN_MEMORY_LIMIT
  responses:
    Unauthorized:
      description: >-
        The `Authorization` header is missing or malformed, or the API token is
        invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Invalid developer token
    InternalError:
      description: >-
        Unexpected error. On endpoints that do not document a `400` for it, this
        is also returned when an ID in the URL is not a valid identifier.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Internal server error. Please try again later.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your CamposCloud API token, sent as `Authorization: Bearer <token>`.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.