{
  "schema_version": 2,
  "id": "commands/copy",
  "title": "COPY",
  "url": "https://redis.io/docs/latest/commands/copy/",
  "summary": "Copies the value of a key to a new key.",
  "since": "6.2.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:32+01:00",
  "page_type": "content",
  "content_hash": "7e5bf96c5ac3c7ed0dd678375d6fe4518c68d3270026d68ef80dbb563bde9e8d",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "> [!NOTE]\n> This command's behavior varies in clustered Redis environments. See the [multi-key operations](https://redis.io/docs/latest/develop/using-commands/multi-key-operations) page for more information.\n\n\nThis command copies the value stored at the `source` key to the `destination`\nkey.\n\nBy default, the `destination` key is created in the logical database used by the\nconnection. The `DB` option allows specifying an alternative logical database\nindex for the destination key.\n\nThe command returns zero when the `destination` key already exists. The\n`REPLACE` option removes the `destination` key before copying the value to it."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>source</code></summary>\n\nThe key to copy from.\n\n</details>\n\n<details open><summary><code>destination</code></summary>\n\nThe key to copy to.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>DB destination-db</code></summary>\n\nCopy the key to the given database index instead of the current one.\n\n</details>\n\n<details open><summary><code>REPLACE</code></summary>\n\nReplace the destination key if it already exists.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "[code example]"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active\\*</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active\\*</nobr></span> | For Active-Active or clustered databases, the source and destination keys must be in the same hash slot.<br /><br />\\*Not supported for stream consumer group info. |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n* [Integer reply](../../develop/reference/protocol-spec#integers): `1` if _source_ was copied.\n* [Integer reply](../../develop/reference/protocol-spec#integers): `0` if _source_ was not copied.\n\n**RESP3:**\n\nOne of the following:\n* [Integer reply](../../develop/reference/protocol-spec#integers): `1` if _source_ was copied.\n* [Integer reply](../../develop/reference/protocol-spec#integers): `0` if _source_ was not copied."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "SET dolly \"sheep\"\nCOPY dolly clone\nGET clone",
      "section_id": "examples"
    }
  ]
}
