Skip to content

Commit

Permalink
Add reference for postgres migrate commands
Browse files Browse the repository at this point in the history
Co-authored-by: Trong Nguyen <trong.huu.nguyen@nav.no>
  • Loading branch information
mortenlj and tronghn committed Oct 7, 2024
1 parent e5b94fc commit 972a1dc
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
66 changes: 66 additions & 0 deletions docs/operate/cli/reference/postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,69 @@ nais postgres password rotate appname
| Argument | Required | Description |
|-------------|-----------|-------------------------------------------------------------|
| appname | Yes | Name of application owning the database |


## migrate

Commands used for migrating to a new postgres instance.

<!-- TODO: See also [Migrate](../../../persistence/postgres/how-to/migrate-to-new-instance.md) -->

### migrate setup

Setup will create a new (target) instance with updated configuration, and enable continuous replication of data from the source instance.

```bash
nais postgres migrate setup appname new-instance-name
```

| Argument | Required | Description |
|-------------------|----------|-------------------------------------------------|
| appname | Yes | Name of application owning the database |
| new-instance-name | Yes | Name of the new postgres instance to migrate to |


| Flag | Description |
|-----------|---------------------------------------------------------------------------------------------------------------------------------|
| tier | Tier of new instance. See [Postgres reference](../../../persistence/postgres/reference/README.md#server-size). |
| type | Postgres version of new instance. See [Postgres reference](../../../persistence/postgres/reference/README.md#postgres-version). |
| disk-size | Disk size of new instance. |

### migrate promote

Promote will promote the target instance to the new primary instance, and update the application to use the new instance.

```bash
nais postgres migrate promote appname new-instance-name
```

| Argument | Required | Description |
|-------------------|----------|-------------------------------------------------|
| appname | Yes | Name of application owning the database |
| new-instance-name | Yes | Name of the new postgres instance to migrate to |

### migrate finalize

Finalize will remove the source instance and associated resources after a successful migration.

```bash
nais postgres migrate finalize appname new-instance-name
```

| Argument | Required | Description |
|-------------------|----------|-------------------------------------------------|
| appname | Yes | Name of application owning the database |
| new-instance-name | Yes | Name of the new postgres instance to migrate to |

### migrate rollback

Rollback will roll back the migration, and restore the application to use the original instance.

```bash
nais postgres migrate rollback appname new-instance-name
```

| Argument | Required | Description |
|-------------------|----------|-------------------------------------------------|
| appname | Yes | Name of application owning the database |
| new-instance-name | Yes | Name of the new postgres instance to migrate to |
6 changes: 6 additions & 0 deletions docs/persistence/postgres/how-to/migrate-to-new-instance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Migrate to new instance
tags: [postgres, migrate, how-to]
---

# TODO
2 changes: 1 addition & 1 deletion docs/persistence/postgres/reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ For further reading see [google Cloud SQL PIT recovery](https://cloud.google.com

In case of catastrophic failure in GCP we are running a daily complete backup of the postgresql databases in GCP to an on-prem location. This backup currently runs at 5 am. This is in addition to the regular backups in GCP.

## Postgres vesion
## Postgres version

The Postgres version can be configured in the application spec. The version is defined by the `type` field in the `nais.yaml` file.

Expand Down

0 comments on commit 972a1dc

Please sign in to comment.