11---
2- title : Migrating data from TimescaleDB
3- description : Learn how to migrate data from the TimescaleDB to a PostgreSQL
4- instance.
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.
55---
66
77## Background
88
9- By default, Coder will deploy a Timescale database within the installation's
9+ By default, Coder will deploy a built-in database within the installation's
1010Kubernetes namespace. We recommend using this database _ only_ for evaluation
1111purposes. With this in mind, you might want to migrate the data stored in your
1212Timescale instance over to an out-of-cluster PostgreSQL database
@@ -15,27 +15,33 @@ Timescale instance over to an out-of-cluster PostgreSQL database
1515
1616## Migration Steps
1717
18- 1 . Access the timescale pod and dump the database into a file:
18+ 1 . Access the database pod and dump the database into a file:
1919
2020``` console
2121kubectl exec -it statefulset/timescale -n coder -- pg_dump -U coder -d coder > backup.sql
2222```
2323
24- > If your database is large, you can truncate Coder's telemetry, metrics, and
25- > 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 to reduce the file size:
2626
27- 1 . Access your PostgreSQL instance and create user ` coder `
27+ ``` psql
28+ TRUNCATE metric_events;
29+ TRUNCATE environment_stats;
30+ TRUNCATE audit_logs;
31+ ```
32+
33+ 1. Access your PostgreSQL instance and create user and database `coder`
2834
29351. Import the data into your database:
3036
31- ``` console
32- cat backup.sql > psql -U coder
37+ ``` psql
38+ psql -U coder < backup.sql
3339```
3440
35411 . Connect your Coder instance to the database:
3642
3743``` console
38- helm upgrade -n coder coder coder/coder \
44+ helm upgrade --reuse-values - n coder coder coder/coder \
3945 --set postgres.default.enable=false \
4046 --set postgres.host=<HOST_ADDRESS> \
4147 --set postgres.port=<PORT_NUMBER> \
0 commit comments