# Clone a machine

Copy a machine to try something risky, or run one command in a copy that deletes itself.

## Clone a machine

Cloning is in Terminal. In the app, [make a template](https://osmates.com/docs/templates) and create machines from it instead.

To clone `dev` now, from its snapshot `clean`, or as a clone that deletes itself when it stops:

```sh
osmates vm clone dev scratch
osmates vm clone dev scratch --snapshot clean
osmates vm clone dev scratch --ephemeral
```

A running machine keeps running while it's cloned. A clone takes almost no space until it writes.

A clone has its own name, MAC address, and identity. It keeps its source's shared folders and clipboard setting, but no forwarded ports. A Linux clone doesn't run its source's user-data again.

A Windows clone needs [its own license](https://osmates.com/docs/windows#activate-windows). A macOS clone may need you to [sign in to iCloud again](https://osmates.com/docs/macos#use-icloud). For Xcode work, see [Run Xcode tests in a macOS machine](https://osmates.com/docs/macos-xcode).

## Run one command in a temporary clone

To run the tests of `src` in a clone of `dev`:

```sh
osmates run dev --copy-in src:/srv/src -- make -C /srv/src test
```

This clones `dev`, copies in `src`, and runs the command. Then it deletes the clone and exits with the command's status. `--copy-out` brings files back, with [quarantine information](https://osmates.com/docs/files#open-files-copied-from-a-guest).

Without a machine name, `osmates run` uses the [template for agents](https://osmates.com/docs/templates#the-template-for-agents). These clones have no shared folders or forwarded ports.
