# Quickstart

> Install oddk, create a Postgres instance, connect over SSH, and set up snapshots and alerts.

Source: https://oddk.dev/docs/quickstart/
Project: https://github.com/AndrianBdn/oddk


## Install on your server

Use a Linux host (x86_64 or arm64) with Docker running and systemd. Run this on
the server; the installer configures the CLI for the user who runs it:

```bash
curl -fsSL https://oddk.dev/install | sh
```

See [Install](../install/) for version pinning and updates. Run the remaining
`oddk` commands on this server.

## Create an instance

Four CPUs, 8 GB of RAM, listening on 5432. The image is pulled automatically if
it isn't already local.

```bash
oddk create --name app --version 17 --port 5432 --cpu 4 --ram 8
```

The command blocks until Postgres actually accepts connections. If readiness is
never reached, oddk rolls back the container and volume rather than leaving you a
broken instance.

## Get a connection string

The password is generated at create time and encrypted at rest.

```bash
oddk instance get-postgres-password app --conn
# postgresql://postgres:••••••••@10.88.0.1:5432/postgres
```

## Provision a database and its owner

```bash
oddk instance create-db app --database billing --username billing
```

This creates both in one step and prints the generated password and connection
string. If database creation fails, the just-created user is rolled back.

## Connect from your laptop

The connection string's `10.88.0.1` address belongs to the server's local Docker
bridge. From your laptop, open an SSH tunnel, replacing `user@db01` with your
SSH login and server address:

```bash
ssh -N -o ExitOnForwardFailure=yes \
  -L 127.0.0.1:15432:10.88.0.1:5432 user@db01
```

Leave that terminal open. In another local terminal, connect with `psql`:

```bash
psql -h 127.0.0.1 -p 15432 -U billing -d billing -W
```

Enter the password printed by `create-db`. In a graphical database client,
use the same host, port, database and user. The tunnel uses local port `15432`
so it can coexist with a local Postgres server on `5432`.

## Protect it

On the server, enable the nightly snapshot:

```bash
oddk snapshot setup-cron --utc-hour 3          # nightly, whole deployment
```

A local snapshot is lost with the server. Before relying on the schedule:

1. [Configure and test offsite copies](../snapshots/#configure-offsite-copies).
2. [Back up the master key separately](../snapshots/#back-up-the-master-key).
3. [Configure and test a notification channel](../notifications/#configure-a-channel).

Then check coverage and address any findings:

```bash
oddk checklist
```

See [Snapshots & recovery](../snapshots/#rebuild-a-whole-host) for the recovery
procedure, or [Tuning](../tuning/) to adjust your instance's parameters.

