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.
- Stop Chatwoot service to stop database activity.
sudo systemctl stop chatwoot.target
- Back up the database using
pg_dump -Fc --no-acl --no-owner -U postgres chatwoot_production > /tmp/cw.dump
Create an RDS Postgres instance in your aws account. Refer https://aws.amazon.com/getting-started/hands-on/create-connect-postgresql-db/.
Verify connectivity to the new RDS instance from your Chatwoot installation.
psql -h <hostname> -u <username> -d postgres
- Restore the database from the backup file.
pg_restore --verbose --clean --no-acl --no-owner --create -U postgres -d postgres /tmp/cw.dump
- Modify the Postgres related environment variables to use the new RDS credentials.
sudo -i -u chatwoot
- Start the Chatwoot service.
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.
sudo cwctl --console