본문 바로가기
WIKI 기술 지식 베이스

데이터베이스 복원

원문 보기 위키 갱신

최근 5일 이내에 삭제된 데이터베이스를 삭제된 그 순간 그대로 복원하는 API예요. 유료 플랜, 조직의 admin 또는 owner 권한, 조직에 복구 기능이 활성화되어 있어야 해요.

출처: 문서

본문

v1 엔드포인트와 달리 이 엔드포인트는 조직과 데이터베이스를 UUID로 식별해요 — 조직 조회의 id 필드와 삭제된 데이터베이스 목록의 DbId 필드를 사용하세요.

요청 예시:

curl -L -X POST 'https://api.turso.tech/v3/organizations/{organizationId}/databases/{databaseId}/restore' \
  -H 'Authorization: Bearer ***'

새 이름으로 복원하는 요청 예시:

curl -L -X POST 'https://api.turso.tech/v3/organizations/{organizationId}/databases/{databaseId}/restore' \
  -H 'Authorization: Bearer ***' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "my-restored-database" }'

OpenAPI

openapi: 3.0.1
info:
  title: Turso Platform API
  description: API description here
  license:
    name: MIT
  version: 0.1.0
servers:
  - url: https://api.turso.tech
    description: Turso's Platform API
security: []
paths:
  /v3/organizations/{organizationId}/databases/{databaseId}/restore:
    post:
      summary: Restore Database
      description: >-
        Restore a database deleted within the last five days, exactly as it was
        at the moment it was deleted. Requires a paid plan, an admin or owner of
        the organization, and recovery enabled for the organization.
      operationId: restoreDatabase
      parameters:
        - $ref: '#/components/parameters/organizationId'
        - $ref: '#/components/parameters/databaseId'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: >-
                    Optional new name for the restored database. If omitted, the
                    original name is reused. The hostname is re-derived from the
                    name.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  database:
                    $ref: '#/components/schemas/DeletedDatabase'
                    description: The restored database.
        '400':
          description: >-
            Recovery is disabled for the organization, or the request is
            invalid.
        '403':
          description: >-
            The organization is on the free plan, or the caller is not an admin
            or owner.
        '404':
          description: >-
            No deleted database with this UUID exists, or its recovery window
            has passed.
components:
  parameters:
    organizationId:
      name: organizationId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: >-
        The UUID of the organization. Retrieve it with the Retrieve Organization
        endpoint (the `id` field).
    databaseId:
      name: databaseId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: >-
        The UUID of the database, as returned when listing deleted databases
        (the `DbId` field).
  schemas:
    DeletedDatabase:
      type: object
      properties:
        Name:
          type: string
          description: The database name.
        DbId:
          type: string
          format: uuid
          description: The database UUID. Use it to restore the database.
        Hostname:
          type: string
          description: >-
            The DNS hostname the database had, used for client and HTTP
            connections.
        group:
          type: string
          description: The name of the group the database belonged to.
        group_id:
          type: string
          format: uuid
          description: The UUID of the group the database belonged to.
        organization_id:
          type: string
          format: uuid
          description: The UUID of the organization.
        regions:
          type: array
          items:
            type: string
          description: The regions the database was located in.
        primaryRegion:
          type: string
          description: The primary region of the database.
        delete_protection:
          type: boolean
          description: Whether delete protection was enabled for the database.
        deleted_at:
          type: string
          format: date-time
          description: When the database was deleted.
        group_deleted_at:
          type: string
          format: date-time
          description: >-
            Set when the database's group was deleted with it. Restoring the
            database also restores the group.

더 알아보기 (Learn more)