# Replace a Restore

URL: /docs/api/disaster-recovery/restore/replace

`PUT /apis/funcd.io/v1alpha1/namespaces/{namespace}/restores/{name}`

## Authentication

One of:

- `bearer`: A credential of funcd's config, sent as Authorization: Bearer followed by its token.
- `apiKey`: A credential of funcd's config, sent in the X-Api-Key header.

## Parameters

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `namespace` | path | string, required | The object's namespace. |
| `name` | path | string, required | The object's name. |
| `dryRun` | query | boolean | Admit the write and store nothing. |
| `If-Match` | header | string | One strong entity-tag, the quoted resourceVersion, or *: the write is conditional on it. |

## Body

`Restore` as `application/json`, required.

```json
{
  "additionalProperties": false,
  "properties": {
    "apiVersion": {
      "type": "string"
    },
    "kind": {
      "type": "string"
    },
    "metadata": {
      "additionalProperties": false,
      "properties": {
        "creationTimestamp": {
          "description": "When funcd created the object.",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
          "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
          "type": "string"
        },
        "deletionTimestamp": {
          "description": "When funcd held the object at its deletion: an object of an Engineless add-on kind with deletion: delete stays, deleting, until its Function has destroyed what it holds. funcd sets it on no other object, and a write keeps it.",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
          "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
          "type": "string"
        },
        "finalizers": {
          "description": "funcd does not read it.",
          "items": {
            "type": "string"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "generateName": {
          "description": "A prefix from which funcd makes the name, adding a random suffix, when a create leaves name empty.",
          "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
          "type": "string"
        },
        "generation": {
          "description": "Set by funcd: 1 when the object is created, then one more each time its spec changes.",
          "format": "int64",
          "type": "integer"
        },
        "name": {
          "description": "The object's name, unique among the objects of its kind in its namespace. A create may leave it empty and set generateName instead.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "namespace": {
          "description": "The namespace the object belongs to. A cluster-scoped kind has none.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "ownerReferences": {
          "description": "The objects that own this one. funcd deletes an owned object when its owner goes.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "blockOwnerDeletion": {
                "description": "funcd does not read it.",
                "type": "boolean"
              },
              "controller": {
                "description": "Whether this owner is the one that manages the object.",
                "type": "boolean"
              },
              "kind": {
                "description": "The kind of the object it names.",
                "type": "string"
              },
              "name": {
                "description": "The name of the object it names.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "namespace": {
                "description": "The namespace of the object it names.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "uid": {
                "description": "The owner's unique ID.",
                "type": "string"
              }
            },
            "required": [
              "uid",
              "kind",
              "name"
            ],
            "type": "object"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "resourceGroup": {
          "description": "The resource group the object belongs to, within its namespace.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "resourceVersion": {
          "description": "An opaque version of the stored object, which funcd sets. An update that sends it gets a conflict when the object changed since; compare it for equality only.",
          "type": "string"
        },
        "tags": {
          "additionalProperties": {
            "type": "string"
          },
          "description": "Labels on the object, as keys and values.",
          "type": "object"
        },
        "uid": {
          "description": "The object's unique ID, which funcd sets when it creates the object.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "spec": {
      "additionalProperties": false,
      "properties": {
        "backup": {
          "description": "The Backup to load, in the Restore's namespace. The Restore waits while it is Pending or Running, and fails with reason BackupNotReady when it is missing or Failed.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "members": {
          "description": "The members of the Backup to load, at least one and each once, loaded in this order after funcd has checked the whole copy and every destination. A Bucket's member leaves its destination's Lake prefixes as they are: to restore those Lakes, name them as members too.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "as": {
                "description": "The destination: the name of an existing, empty store of the member's kind in the namespace, or for a volume, of a Function whose local volume of that name is empty. A SQLDatabase is empty with no table, view, index or trigger and no Function binding it. Exactly one of as, asLocation and inPlace; a Lake takes asLocation or inPlace.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "asLocation": {
                "additionalProperties": false,
                "properties": {
                  "bucket": {
                    "description": "A Bucket of the same namespace.",
                    "maxLength": 63,
                    "minLength": 1,
                    "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                    "type": "string"
                  },
                  "prefix": {
                    "description": "A prefix of that Bucket.",
                    "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                    "type": "string"
                  }
                },
                "required": [
                  "bucket",
                  "prefix"
                ],
                "type": "object",
                "description": "For a Lake: the bucket and prefix that receive its copy, where no Lake is located and nothing is stored yet; a Lake located there afterwards reads it. The bucket must exist and may not be one this Restore restores in place. Exactly one of as, asLocation and inPlace."
              },
              "inPlace": {
                "description": "Load the member back into its own store, replacing its data; a Function's volume is loaded only when empty or named by its Function's DataMissing condition. The Restore then needs update on the Namespace, as an admin has, and another in-place Restore of the namespace is refused until it ends. It first takes the export Backup that status.export names, which needs the restored Backup's schedule, then holds the namespace while it loads: a failed load keeps the hold until funcdctl hold release --namespace. Exactly one of as, asLocation and inPlace.",
                "type": "boolean"
              },
              "kind": {
                "description": "The member's kind, as the Backup's status.members lists it: KVStore, Bucket, Lake, SQLDatabase, Function for a Function's local volume, or an add-on's kind for an add-on object, which takes inPlace only.",
                "type": "string"
              },
              "name": {
                "description": "The member's name, as the Backup's status.members lists it: the store's, or for a volume, its Function's. A member the copy does not hold fails the Restore with reason MemberNotFound.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "volume": {
                "description": "With kind Function, which needs it, the name of the Function's local volume that the member is. Any other kind takes none.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              }
            },
            "required": [
              "kind",
              "name"
            ],
            "type": "object"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "source": {
          "additionalProperties": false,
          "properties": {
            "credentialsSecret": {
              "description": "A Secret of the namespace with AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and, optionally, AWS_SESSION_TOKEN: the key the Restore reads the copy with, at the Backup's status.target. A read-only key is enough.",
              "maxLength": 63,
              "minLength": 1,
              "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
              "type": "string"
            },
            "identitySecret": {
              "description": "A Secret of the namespace whose AGE_IDENTITY key holds age identities, X25519 or hybrid and not passphrase-encrypted, one of them for a recipient the Backup is sealed to. It is required: a Restore without it is refused.",
              "maxLength": 63,
              "minLength": 1,
              "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
              "type": "string"
            }
          },
          "required": [
            "credentialsSecret"
          ],
          "type": "object",
          "description": "The Secrets that read the Backup's copy and open its seal."
        }
      },
      "required": [
        "backup",
        "source",
        "members"
      ],
      "type": "object"
    },
    "status": {
      "additionalProperties": false,
      "properties": {
        "completionTime": {
          "description": "When the Restore ended, Succeeded or Failed.",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
          "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
          "type": "string"
        },
        "conditions": {
          "description": "The conditions that explain the phase.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "lastTransitionTime": {
                "description": "When the status last changed.",
                "format": "date-time",
                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
                "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
                "type": "string"
              },
              "message": {
                "description": "A sentence that explains the status.",
                "type": "string"
              },
              "observedGeneration": {
                "description": "The object's generation when funcd set the condition.",
                "format": "int64",
                "type": "integer"
              },
              "reason": {
                "description": "A short CamelCase reason for the status.",
                "type": "string"
              },
              "status": {
                "description": "Whether the condition holds.",
                "type": "string"
              },
              "type": {
                "description": "What the condition reports, such as Ready.",
                "type": "string"
              }
            },
            "required": [
              "type",
              "status"
            ],
            "type": "object"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "export": {
          "description": "The Backup that an in-place Restore takes before it loads, <restore>-before, of the restored Backup's schedule. Empty when no member is in place.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "observedGeneration": {
          "description": "The generation of the spec that funcd last acted on.",
          "format": "int64",
          "type": "integer"
        },
        "phase": {
          "description": "Pending while it waits for its Backup and, in place, for its export; Running while it checks the whole copy and loads; then Succeeded or Failed. A Restore that was Running when funcd stopped ends Failed with reason Interrupted.",
          "enum": [
            "Pending",
            "Running",
            "Paused",
            "Succeeded",
            "Failed",
            "Cancelled"
          ],
          "type": "string"
        },
        "startTime": {
          "description": "When the Restore turned Running, once its Backup and any export had Succeeded.",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
          "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "required": [
    "metadata",
    "spec",
    "apiVersion",
    "kind"
  ],
  "type": "object"
}
```

## Answers

| Status | Problem type | When | What to do |
| --- | --- | --- | --- |
| 200 |  | OK |  |
| 400 | `urn:funcd:problem:invalid` | The If-Match header is not one strong entity-tag, such as "42", or *. | Send one If-Match line with the quoted resourceVersion, or *. |
| 400 | `urn:funcd:problem:invalid` | A field breaks a rule that the schema cannot hold, which the detail names. | Correct the field that the detail names. |
| 400 | `urn:funcd:problem:invalid` | The body's metadata.namespace or metadata.name is not the path's, or If-Match and metadata.resourceVersion name two versions. | Send the object to its own path, with at most one version. |
| 400 | `about:blank` | The body is missing or is not JSON. | Send a JSON body. |
| 400 | `urn:funcd:problem:invalid` | The spec differs from the stored Restore's: the spec of a Restore does not change. | Create another Restore instead. |
| 401 | `urn:funcd:problem:unauthorized` | The request carries no bearer token or API key, or one that funcd does not know. | Send a credential of funcd's config as a bearer token in the Authorization header, or in X-Api-Key. |
| 403 | `urn:funcd:problem:forbidden` | The credential's role or namespaces do not allow it to replace a Restore in the namespace. | Use a credential whose role allows it, such as a developer of the namespace or an admin. |
| 404 | `urn:funcd:problem:not-found` | No Restore of that name exists in the namespace. | Check the name and the namespace. |
| 409 | `urn:funcd:problem:conflict` | The Restore has changed since the resourceVersion that If-Match or metadata.resourceVersion names. | Read the Restore again, apply the change to it, and send it with its new resourceVersion. |
| 413 | `urn:funcd:problem:payload-too-large` | The body is larger than 1 MiB. | Send a smaller body. |
| 415 | `about:blank` | The Content-Type of the body is not JSON. | Send the body as application/json. |
| 422 | `about:blank` | The namespace or the name in the path is not a DNS-1123 label. | Use at most 63 lowercase letters, digits and hyphens, starting and ending with a letter or a digit. |
| 422 | `about:blank` | The query holds a parameter that the operation does not take. | Send only the parameters that the operation lists. |
| 422 | `about:blank` | The dryRun parameter is neither true nor false. | Send dryRun=true, or leave it out. |
| 422 | `about:blank` | The body breaks the schema: a field that it does not know, of the wrong type or past its limits. | Correct the field at the location that the detail gives. |