76 lines
2.0 KiB
Plaintext
76 lines
2.0 KiB
Plaintext
---
|
|
title: "How to migrate Chatwoot database?"
|
|
description: "Learn how to migrate your Chatwoot database from bundled PostgreSQL to managed database services like AWS RDS"
|
|
---
|
|
|
|
## Chatwoot database migration
|
|
|
|
Follow along If you started out with a bundled install of postgres, redis and chatwoot in a single instance
|
|
and now wants to migrate to managed database service.
|
|
|
|
In this guide, we assume you want to migrate to AWS RDS. This guide should be equally applicable to any other
|
|
managed database service or even migrating data between different Chatwoot installations.
|
|
|
|
### Step 1: Stop Chatwoot service
|
|
|
|
Stop Chatwoot service to stop database activity.
|
|
|
|
```bash
|
|
sudo systemctl stop chatwoot.target
|
|
```
|
|
|
|
### Step 2: Back up the database
|
|
|
|
Back up the database using `pg_dump` tool.
|
|
|
|
```bash
|
|
pg_dump -Fc --no-acl --no-owner -U postgres chatwoot_production > /tmp/cw.dump
|
|
```
|
|
|
|
### Step 3: Create RDS instance
|
|
|
|
Create an RDS Postgres instance in your AWS account. Refer to the [AWS documentation](https://aws.amazon.com/getting-started/hands-on/create-connect-postgresql-db/).
|
|
|
|
### Step 4: Verify connectivity
|
|
|
|
Verify connectivity to the new RDS instance from your Chatwoot installation.
|
|
|
|
```bash
|
|
psql -h <hostname> -u <username> -d postgres
|
|
```
|
|
|
|
### Step 5: Restore the database
|
|
|
|
Restore the database from the backup file.
|
|
|
|
```bash
|
|
pg_restore --verbose --clean --no-acl --no-owner --create -U postgres -d postgres /tmp/cw.dump
|
|
```
|
|
|
|
### Step 6: Update environment variables
|
|
|
|
Modify the Postgres related environment variables to use the new RDS credentials.
|
|
|
|
```bash
|
|
sudo -i -u chatwoot
|
|
cd chatwoot
|
|
vi .env
|
|
```
|
|
|
|
### Step 7: Start Chatwoot service
|
|
|
|
Start the Chatwoot service.
|
|
|
|
```bash
|
|
sudo systemctl start chatwoot.target
|
|
```
|
|
|
|
<Note>
|
|
If you are getting the Chatwoot onboarding screen again on visiting your self-hosted Chatwoot URL,
|
|
login to the rails console and run the following:
|
|
|
|
```bash
|
|
sudo cwctl --console
|
|
::Redis::Alfred.delete(::Redis::Alfred::CHATWOOT_INSTALLATION_ONBOARDING)
|
|
```
|
|
</Note> |