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

# Restore database

> Restore a database to a backup or a point in time, either into a new database (`clone_to_new: true`) or over this one (`in_place: true`).

Choose the restore point with `backup_id` (a completed backup with `restorable: true`) or, for PostgreSQL, `pitr_timestamp` (any time from `restore_window_start` on the backup list until now). Omit both to restore the latest available state. A point outside the window returns `400`.

- **New database**: inherits the source's plan, storage, VPC, and project, starts with no read replicas, and bills pay-as-you-go. High availability is an explicit choice via `ha_enabled`, never inherited. If `new_name` is taken, the platform adds a suffix (`-2`, `-3`, …). Poll `GET /api/v1/databases/{new_database_id}` like any create. Free databases cannot restore into a new database.
- **In place**: overwrites this database. A safety backup is taken first, the status is `restoring` while it runs, and `new_database_id` is empty. Data written after the restore point is lost.




## OpenAPI

````yaml POST /api/v1/databases/{database_id}/restore
openapi: 3.0.3
info:
  title: Raff API
  description: >
    REST API for managing cloud infrastructure on Raff.


    ## Authentication

    Most endpoints require authentication via API key. Catalog endpoints under
    `/api/v1/public/` are open and require no authentication.


    ### API Key Authentication

    Include your API key in the `X-API-Key` header:
      ```
      curl -H "X-API-Key: YOUR_API_KEY" https://api.rafftechnologies.com/api/v1/vms
      ```

    ## Catalog

    Use the public catalog endpoints to discover available regions, OS
    templates, and pricing plans before creating resources:

    - `GET /api/v1/public/regions` — list available regions

    - `GET /api/v1/public/templates` — list OS templates (use the `id` as
    `template_id` when creating a VM)

    - `GET /api/v1/public/pricing/vm` — list VM pricing plans (use the `id` as
    `pricing_id` when creating a VM)

    - `GET /api/v1/public/pricing/volume` — volume storage pricing

    - `GET /api/v1/public/pricing/snapshot` — snapshot storage pricing

    - `GET /api/v1/public/pricing/backup` — backup storage pricing

    - `GET /api/v1/public/pricing/ip` — IP address pricing

    - `GET /api/v1/public/pricing/database` — managed database pricing (plans,
    high availability, read replicas, extra storage)

    - `GET /api/v1/public/pricing/kubernetes` — managed Kubernetes pricing
    (worker node plans, HA control plane, storage nodes)
  version: 1.0.0
  contact:
    name: Raff Technologies
    url: https://rafftechnologies.com
servers:
  - url: https://api.rafftechnologies.com
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Catalog
    description: >-
      Discover available regions, OS templates, and pricing plans. No
      authentication required.
  - name: Health
    description: Health check endpoints
  - name: Projects
    description: Organize resources into projects for billing and access control
  - name: Virtual Machines
  - name: Kubernetes
    description: >-
      Managed Kubernetes clusters — HA control planes, autoscaling node pools,
      kubeconfig access
  - name: Functions
    description: Deploy and manage serverless functions
  - name: Raff Apps
    description: >-
      Push-to-deploy web services, private services, workers, cron jobs, and
      one-off jobs on the Raff PaaS — with custom domains, environment
      variables, autoscaling, and per-second billing with spend caps
  - name: Managed Databases
    description: >-
      Fully managed PostgreSQL and Valkey databases with private VPC networking,
      automatic backups, and metrics
  - name: Networking
    description: >-
      Attach and detach VPCs, floating IPs, and security groups to VM network
      interfaces
  - name: Snapshots
    description: Point-in-time copies of VMs and volumes for quick rollback or cloning
  - name: Backups
    description: Scheduled and on-demand VM backups with restore capability
  - name: Backup Schedules
    description: Recurring daily or weekly backup schedules attached to a VM
  - name: SSH Keys
    description: Manage account-level SSH keys for VM provisioning
  - name: Members
    description: Account-level members — invite, list, update role, remove
  - name: Project Members
    description: Members of a specific project — same model as Members but project-scoped
  - name: Roles
    description: Custom roles bundling account or project permissions
  - name: Permissions
    description: List the catalog of permission strings used by roles
  - name: API Keys
    description: Create and manage API keys for programmatic access
  - name: Invitations
    description: Create and cancel email-based invitations to join the account or a project
paths:
  /api/v1/databases/{database_id}/restore:
    post:
      tags:
        - Managed Databases
      summary: Restore database
      description: >
        Restore a database to a backup or a point in time, either into a new
        database (`clone_to_new: true`) or over this one (`in_place: true`).


        Choose the restore point with `backup_id` (a completed backup with
        `restorable: true`) or, for PostgreSQL, `pitr_timestamp` (any time from
        `restore_window_start` on the backup list until now). Omit both to
        restore the latest available state. A point outside the window returns
        `400`.


        - **New database**: inherits the source's plan, storage, VPC, and
        project, starts with no read replicas, and bills pay-as-you-go. High
        availability is an explicit choice via `ha_enabled`, never inherited. If
        `new_name` is taken, the platform adds a suffix (`-2`, `-3`, …). Poll
        `GET /api/v1/databases/{new_database_id}` like any create. Free
        databases cannot restore into a new database.

        - **In place**: overwrites this database. A safety backup is taken
        first, the status is `restoring` while it runs, and `new_database_id` is
        empty. Data written after the restore point is lost.
      operationId: restoreDatabase
      parameters:
        - $ref: '#/components/parameters/DatabaseIDPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RestoreDatabaseRequest'
      responses:
        '200':
          description: Restore started
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  new_database_id:
                    type: string
                    description: >-
                      Short ID of the new database being created (empty for an
                      in-place restore)
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    DatabaseIDPath:
      name: database_id
      in: path
      required: true
      description: >-
        Database ID (UUID) or short id (the `database_id` field, e.g.
        `a1b2c3d4`)
      schema:
        type: string
  schemas:
    RestoreDatabaseRequest:
      type: object
      description: Set exactly one of `clone_to_new` or `in_place` to `true`.
      properties:
        clone_to_new:
          type: boolean
          description: Restore into a new database
        in_place:
          type: boolean
          description: >-
            Restore over this database. Data written after the restore point is
            lost.
        backup_id:
          type: string
          format: uuid
          description: >-
            Restore from this completed backup. Omit to use `pitr_timestamp` or
            the latest state.
        pitr_timestamp:
          type: string
          format: date-time
          description: >-
            Point-in-time restore target (RFC 3339). PostgreSQL only — Valkey
            restores from snapshots via `backup_id`.
        new_name:
          type: string
          description: >-
            Name for the new database. Defaults to `{source-name}-restored`;
            auto-suffixed (`-2`, `-3`, …) if taken.
        ha_enabled:
          type: boolean
          default: false
          description: >-
            Enable high availability on the new database (+70% of the plan
            price). Never inherited from the source.
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Authentication required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication. Each key is bound to a specific account.

````

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