# Moving to Keel

Most moves follow the same six steps, whatever you're moving from. Each platform's guide fills in the details: [Heroku](./heroku), [Fly.io](./fly), [Render](./render), [Railway](./railway), [Docker Compose](./docker-compose), or [an app already on AWS](./aws).

## 1. Draft keel.yml from what you have

```bash
keel init --from fly.toml        # or docker-compose.yml, render.yaml, app.json, railway.json
```

Keel reads your current platform's file and drafts `keel.yml`: processes, ports, health checks, the release command, cron jobs, and a database or cache. Every value is printed with the file and key it came from. Read that list, because this is the moment to correct anything it got wrong.

Two things it never does:
- **It never copies a value.** Environment variables become `secrets:` names, and you set each value in step 3.
- **It never silently drops something.** Anything it couldn't translate, such as a prebuilt image or a Fly region, is named with the reason.

Without a `--from` file, `keel init` reads the source tree instead (a Gemfile, a Procfile, a `package.json`) and does the same.

## 2. Decide where it runs

By default each environment gets its own VPC. If the app needs to reach something already in AWS, such as a database or an internal service, run it in that VPC instead. `keel init` lists the VPCs in the account that could carry the app, or you can set `vpc.id` and its subnets yourself. See [Running in an existing VPC](/guide/configuration#existing-vpc).

Decide before the first `keel up`: an environment can't move between its own VPC and an existing one in place.

## 3. Set the secrets

For each name step 1 listed:

```bash
keel config set SECRET_KEY_BASE=...
```

If the values are already in SSM Parameter Store or Secrets Manager, copy them instead:

```bash
keel adopt secrets --ssm-path /myapp/prod/
```

Keel provides the database's own credentials as `DATABASE_HOST`, `DATABASE_USER`, `DATABASE_PASSWORD` and the rest, not as a `DATABASE_URL`. If your app expects a URL, read [composing one safely](/database-credentials#there-is-no-database-url-and-composing-one-needs-care) before writing one by hand.

## 4. Create the infrastructure

```bash
keel cost        # what it will cost, before anything exists
keel up          # plan, confirm, apply
```

## 5. Bring the data

Export from the old platform, then load it into the new database through a tunnel:

```bash
keel db import app.dump
```

`keel db import` reads the dump's format from the file: plain SQL, a PostgreSQL custom-format dump, or either gzipped.
- **It refuses a database that already has tables**, unless you pass `--allow-non-empty`.
- **A PostgreSQL import runs as one transaction**, so a failure loads nothing.
- **You confirm by typing the environment's name.**

If the database is already in RDS, don't copy it: [adopt it](./aws#adopt-the-database).

## 6. Deploy, then move the domain

```bash
keel deploy
keel status
```

Check the app on its load balancer address, then move traffic:

1. Lower the TTL on the domain's current record a day ahead, so the change takes effect quickly.
2. Point the domain at Keel:
   - `keel domains add example.com` handles all three DNS arrangements;
   - `keel adopt zone example.com` uses a Route 53 zone you already have.
3. Run `keel up` to issue the certificate and create the record.
4. Run `keel domains status` until it reports the domain is serving.

Keep the old platform running until traffic has moved. Then stop writes there and do a final `keel db import --allow-non-empty`, or plan a short maintenance window if the data can't be merged.
