# Copy & Sync **Page:** foundation/computers/copy-sync [Download Raw Markdown](./foundation/computers/copy-sync.md) --- # Copy & Sync A copy is a complete, independent duplicate of a computer, and it can land in a different project or on a different server. A copy can start from a [snapshot](/foundation/computers/snapshots/) you choose. Syncing a copy with its source is not available yet: to get the source's later changes, [copy the source again](#get-the-sources-later-changes). A scoped auth token needs `computers.read` and `computers.create`, plus `computers.features.ai` or `computers.features.hoody_kit` if the source has them. See [request fields](/foundation/computers/copy-sync/reference/#request-fields). This copies production onto an EU server: ```bash # Copy production to EU for redundancy hoody computers copy "$PROD_US_ID" --target-project "$PROJECT_ID" --target-server-id "$EU_SERVER_ID" --name prod-eu-replica ``` ```typescript // Copy production to EU for redundancy const euReplica = await client.api.computers.copy(PROD_US_ID, { target_project_id: PROJECT_ID, target_server_id: EU_SERVER_ID, name: 'prod-eu-replica' }); ``` ```bash # Copy production to EU for redundancy curl -X POST "https://api.hoody.com/api/v1/computers/$PROD_US_ID/copy" \ -H "Authorization: Bearer $HOODY_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "target_project_id": "'"$PROJECT_ID"'", "target_server_id": "'"$EU_SERVER_ID"'", "name": "prod-eu-replica" }' ``` Copies production to the EU server to stand up the replica. To bring the replica up to date later, copy production again and delete the old replica. In the Hub, open **Computers**, open the computer's ⋯ menu and choose **Make a copy…**. Pick the **Name**, **Server** and **Project** for the copy, then press **Make copy**. To give the copy an SSH key or carry over firewall and network rules, use the API or CLI. The replica holds production's state at the time of the copy. A [proxy alias](/foundation/proxy/aliases/) URL includes its server's name, so the replica cannot take over production's alias. Create and test a separate alias for the replica before a failure. If the US datacenter fails, point your users or your own routing at the replica's URL. ## What a copy includes | | | |---|---| | Copied | Root filesystem (files and directories), configuration, including environment variables, installed software (packages, dependencies) and data (databases, user files) | | New on the copy | Its own computer ID and lifecycle, new service URLs that use the destination project ID and the new computer ID, and `source_computer_id` naming the source, which becomes `null` once the source is deleted | | Not copied | The SSH key ([give it one](#give-the-copy-an-ssh-key)); the source's snapshot history, so take fresh snapshots on the copy once it is running; proxy aliases, which are separate configuration (create new ones for the copy); firewall and network rules, unless you ask; contents of `/ramdisk`, if enabled: the copy has its own empty RAM disk, so save any needed contents to persistent storage before copying | **Firewall and network rules are not copied by default.** The copy starts with a fresh network and firewall configuration. To carry the source's rules over, set `copy_firewall_rules: true` and/or `copy_network_rules: true` in the copy request. Copying network rules also disables the copy's autostart setting; enable it again if the copy should start whenever its server starts. The copy runs independently: changes to the copy do not affect the source, and changes to the source do not reach the copy. It keeps running if the source is deleted. Manage it like any other computer ([Managing](/foundation/computers/managing/)). A copy is not charged separately. It counts toward the destination server's computer limit and uses its shared resources. See [Pricing](/foundation/pricing/). ## Choose where the copy lands | You send | The copy lands | |---|---| | `target_project_id` (required) | In that project, on the source's server | | `target_project_id` and `target_server_id` | In that project, on that server; both can differ from the source in one copy | | `name` (optional) | Under that name; it is auto-generated if omitted | Another project suits client demos, separate staging and production projects, personal projects and isolated experiments. Copies must be within your own projects: you cannot copy a computer to a different user's account. [Storage shares](/foundation/storage/sharing-files/) share a folder between your own computers, copies included. Another server gives geographic redundancy, lower latency for nearby users, and disaster recovery in a different datacenter. The copy is slower, because the data crosses the network between servers. ## Copy from a snapshot Pass a snapshot's name as `source_snapshot` to copy from a known-good state instead of the source's current state: Pin one when the source may have changed since you last tested it: you copy files in a state you know is stable (always copy from the v1.0.0 snapshot). The copy still takes the source computer's current environment variables, so keep those separately when you need a reproducible environment. Take the value from the snapshot's `name` field, not its alias ([how a snapshot is named](/foundation/computers/snapshots/#how-is-a-snapshot-named)). An auth token needs `computers.features.snapshots` to use `source_snapshot`. Without `source_snapshot`, the copy takes the source's current state. In the Hub, open **Computers**, select the computer and open the **Backups** tab. On the snapshot's row, choose **New computer from this**, pick the server and project, then press **Make the computer**. ## Give the copy an SSH key A copy never carries its source's SSH key, and cannot be made to. Pass a public key as `ssh_public_key` on the copy request. Omit it and nothing is generated: the copy has no SSH access until you [add a key](/foundation/networking/ssh/#add-the-key-to-a-computer). **Security rule:** Each computer must have unique SSH credentials: a key already on another computer is refused with `409`. Give different team members different keys. ```bash # Omit ssh_public_key → the copy has no SSH key at all POST /api/v1/computers/{source_id}/copy { "target_project_id": "{project}", "name": "copy" } # Give the copy its own key, never the source's POST /api/v1/computers/{source_id}/copy { "target_project_id": "{project}", "name": "copy", "ssh_public_key": "ssh-rsa DIFFERENT_KEY..." } ``` ## Follow a copy until it runs A copy runs asynchronously. It reports `copying` while it duplicates the source's current state, or the `source_snapshot` you name, onto the target server and sets any SSH key you supplied. Then it starts automatically and reports `running`. With `copy_network_rules: true`, a network or startup failure can leave the copy `stopped`. If starting it asks you to configure its network first, reapply its network settings through [Network](/foundation/networking/network/) and start it again. Keep the old computer until the copy reports `running`. ```bash # Check copy status curl "https://api.hoody.com/api/v1/computers/$NEW_COPY_ID" \ -H "Authorization: Bearer $HOODY_TOKEN" # Watch for: "status": "copying" → "status": "running" ``` `hoody computers copy ... --until-done` waits for the copy and exits 1 if it fails, or 124 once `--timeout` (default 10m) passes. A failed copy shows `status: "failed"` and cannot be started: delete it and copy again ([troubleshooting](/foundation/computers/copy-sync/reference/#troubleshooting)). Typical durations by size are in [copy timing](/foundation/computers/copy-sync/reference/#copy-timing). ## Get the source's later changes Syncing a copy with its source is not available yet. `POST /api/v1/computers/{id}/sync` answers `409` with `COMPUTER_SYNC_UNAVAILABLE` for a copy you may update. The copy is left exactly as it was: no files change and its status does not move ([sync errors](/foundation/computers/copy-sync/reference/#sync-errors)). Copy the source again when it has updates you need: a production deployment, template improvements, security patches. The new copy holds the source's current state, or the `source_snapshot` you name. It gets a new computer ID and service URLs and can go to another project or server. An alias cannot be moved to it: to keep an alias name, delete the [proxy alias](/foundation/proxy/aliases/) and create it again for the new copy. The alias URL changes if the destination uses a different `server_name`; check the new alias's returned `url`. Data that exists only on the old copy is not carried over. Move anything you need out of it before you delete it. ```bash set -eo pipefail # Copy the source again and wait for it (exits 1 if the copy fails) NEW_COPY_ID=$(hoody computers copy "$SOURCE_ID" --target-project "$PROJECT_ID" --name staging-api-2 \ --until-done -o json | jq -er '.response.id') # The copy can finish with the new computer stopped: check that it is running. # If it is stopped or failed, keep the old copy and fix the problem first. [ "$(hoody computers get "$NEW_COPY_ID" -o json | jq -r '.status')" = "running" ] # The new copy is running: delete the old one hoody computers delete "$OLD_COPY_ID" --yes ``` ```typescript // Copy the source again const fresh = await client.api.computers.copy(SOURCE_ID, { target_project_id: PROJECT_ID, name: 'staging-api-2' }); // Wait until the new copy is running; stop if it failed or was left stopped let status = fresh.data.status; while (status !== 'running') { if (status === 'failed') throw new Error('Copy failed; the old copy is kept'); if (status === 'stopped') throw new Error('Copy did not start; check its status and network configuration. The old copy is kept'); await new Promise((resolve) => setTimeout(resolve, 5000)); status = (await client.api.computers.get(fresh.data.id!)).data.status; } // Delete the old copy once the new one is running await client.api.computers.delete(OLD_COPY_ID); ``` ```bash set -eo pipefail # Copy the source again NEW_COPY_ID=$(curl -sf -X POST "https://api.hoody.com/api/v1/computers/$SOURCE_ID/copy" \ -H "Authorization: Bearer $HOODY_TOKEN" \ -H "Content-Type: application/json" \ -d '{"target_project_id": "'"$PROJECT_ID"'", "name": "staging-api-2"}' | jq -r '.data.id') # Wait until the new copy is running; stop if it failed or was left stopped while true; do STATUS=$(curl -sf "https://api.hoody.com/api/v1/computers/$NEW_COPY_ID" \ -H "Authorization: Bearer $HOODY_TOKEN" | jq -r '.data.status') [ "$STATUS" = running ] && break [ "$STATUS" = failed ] && { echo "Copy failed; the old copy is kept" >&2; exit 1; } [ "$STATUS" = stopped ] && { echo "Copy did not start; check its status and network configuration. The old copy is kept" >&2; exit 1; } sleep 5 done # Delete the old copy once the new one is running curl -sf -X DELETE "https://api.hoody.com/api/v1/computers/$OLD_COPY_ID" \ -H "Authorization: Bearer $HOODY_TOKEN" ``` Creates a fresh copy, then deletes the old one. Open the check link (NEW_COPY_ID is the new copy's `data.id`); run the delete only once it reports `running`, and keep the old copy if it reports `failed` or `stopped`. ## Find the copies of a computer A computer whose `source_computer_id` is not null is a copy of the computer it names: ```json { "data": { "id": "01bcdef123456789abcdef01", "source_computer_id": "890abcdef12345678901cdef", ... } } ``` To find all copies of a source, filter the computer list by `source_computer_id`. The SDK's `listAll()` follows pagination but throws after 1,000 pages if more results remain; past that, request each `page` yourself with `list()`. `hoody computers list` follows pages up to 10,000 items or 1,000 requests and warns when more results remain. Over HTTP, request each `page` ([example](/foundation/computers/copy-sync/reference/#find-all-copies)): ## Advanced - **Copy many computers:** copy and sync requests share an account-wide limit, by default 10 per 5 minutes and 20 per hour; over it, `429` starts nothing. Fan out in bounded batches ([batch script](/foundation/computers/copy-sync/reference/#copy-many-computers)). - **KVM on the copy:** never inherited. `kvm: true` is refused (`403`) on free-tier and subserver targets; on a dedicated server the copy comes back `kvm: false` with a `kvm_note`: enable KVM once it is stopped ([Virtual Machines](/foundation/servers/virtual-machines/#copy-a-computer-with-kvm)). - **Outcome events:** when the copy answer carries an `operation_id`, the `computer.operation.completed` or `computer.operation.failed` event reports the outcome with the same value ([Copy & Sync API page](/api/computer-copy-sync/)). - **Recipes:** ready flows for refreshing staging, team templates, production-to-staging-to-development chains, multi-region copies, snapshot-copy-deploy and A/B tests ([recipes](/foundation/computers/copy-sync/reference/#recipes)). ## Reference Tables, recipes and troubleshooting: the [Copy & Sync reference](/foundation/computers/copy-sync/reference/). ## What's next - [Snapshots](/foundation/computers/snapshots/): the source for a pinned copy - [Images](/foundation/computers/images/): template computers from images - [Create, Edit, Delete](/foundation/computers/create-edit-delete/): computer fundamentals - [Proxy Aliases](/foundation/proxy/aliases/): create an alias for a copy