Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.

Commit 2719337

Browse files
author
Katie Horne
committed
Edit text
1 parent a717894 commit 2719337

File tree

1 file changed

+42
-41
lines changed

1 file changed

+42
-41
lines changed
Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,61 @@
11
---
2-
title: Migrating data from Coder's built-in PostgreSQL database
3-
description: Learn how to migrate data from the built-in PostgreSQL to an
4-
external PostgreSQL instance.
2+
title: Migrating data Coder's database
3+
description: Learn how to migrate data from Coder's built-in PostgreSQL database
4+
to an external PostgreSQL instance.
55
---
66

7-
## Background
7+
By default, Coder deploys a built-in database in the installation's Kubernetes
8+
namespace. We recommend using this database _only_ for evaluation purposes.
89

9-
By default, Coder will deploy a built-in database within the installation's
10-
Kubernetes namespace. We recommend using this database _only_ for evaluation
11-
purposes. With this in mind, you might want to migrate the data stored in your
12-
Timescale instance over to an out-of-cluster PostgreSQL database
10+
At the end of your evaluation period, you may need to migrate the data from the
11+
built-in database to an out-of-cluster PostgreSQL database for production use.
12+
This article will walk you through the process of doing so.
1313

14-
**Note**: The following steps require Kubernetes cluster-admin access.
14+
> You must be a cluster admin for your Kubernetes cluster.
1515
1616
## Migration Steps
1717

1818
1. Access the database pod and dump the database into a file:
1919

20-
```console
21-
kubectl exec -it statefulset/timescale -n coder -- pg_dump -U coder -d coder > backup.sql
22-
```
20+
```console
21+
kubectl exec -it statefulset/timescale -n coder -- pg_dump -U coder -d coder > backup.sql
22+
```
2323

24-
1. (Optional) If your database is large, you can truncate Coder's telemetry,
25-
metrics, and audit log to reduce the file size:
24+
1. **Optional**: If your database is large, you can truncate Coder's telemetry,
25+
metrics, and audit log data to reduce the file size:
2626

27-
```psql
28-
TRUNCATE metric_events;
29-
TRUNCATE environment_stats;
30-
TRUNCATE audit_logs;
31-
```
27+
```psql
28+
TRUNCATE metric_events;
29+
TRUNCATE environment_stats;
30+
TRUNCATE audit_logs;
31+
```
3232

3333
1. Access your PostgreSQL instance and create user and database `coder`
3434

35-
1. Import the data into your database:
35+
1. Import the data you exported in the first step into your external database:
3636

37-
``` psql
38-
psql -U coder < backup.sql
39-
```
37+
```psql
38+
psql -U coder < backup.sql
39+
```
4040

4141
1. Connect your Coder instance to the database:
4242

43-
```console
44-
helm upgrade --reuse-values -n coder coder coder/coder \
45-
--set postgres.default.enable=false \
46-
--set postgres.host=<HOST_ADDRESS> \
47-
--set postgres.port=<PORT_NUMBER> \
48-
--set postgres.user=<DATABASE_USER> \
49-
--set postgres.database=<DATABASE_NAME> \
50-
--set postgres.passwordSecret=<secret-name> \
51-
--set postgres.sslMode=require
52-
```
53-
54-
1. (Optional) If you'd like to delete the Timescale persistent volume, run:
55-
56-
```console
57-
kubectl delete pvc timescale-data-timescale-0 -n coder
58-
```
59-
60-
At this point, you should be able to successfully login to your Coder deployment.
43+
```console
44+
helm upgrade --reuse-values -n coder coder coder/coder \
45+
--set postgres.default.enable=false \
46+
--set postgres.host=<HOST_ADDRESS> \
47+
--set postgres.port=<PORT_NUMBER> \
48+
--set postgres.user=<DATABASE_USER> \
49+
--set postgres.database=<DATABASE_NAME> \
50+
--set postgres.passwordSecret=<secret-name> \
51+
--set postgres.sslMode=require
52+
```
53+
54+
1. **Optional**: If you'd like to delete the Timescale persistent volume, run:
55+
56+
```console
57+
kubectl delete pvc timescale-data-timescale-0 -n coder
58+
```
59+
60+
At this point, you should be able to log in to your Coder deployment
61+
successfully.

0 commit comments

Comments
 (0)