How to Move a Production Discourse PostgreSQL Database to Development
On Your Production Server
Note: This assumes you are running Discourse in a "two container" configuration. Please adjust your container name as required:
docker exec -it data bash
cd /shared
mkdir dumps
chown postgres dumps
su postgres
cd dumps
pg_dump discourse -f discourse.sql
gzip discourse.sql
Move that file over to your development server using any file transfer utility you like (for example, sftp
).
On Your Development Server
sftp> cd /shared/data/dumps/
sftp> get discourse.sql.gz
sftp> exit
Reinitialize discourse_development DB on development server
psql> CREATE USER postgres;
psql> CREATE USER discourse;
psql> DROP DATABASE discourse_development;
psql> CREATE DATABASE discourse_development;
psql> GRANT ALL PRIVILEGES ON discourse_development TO postgres;
psql> GRANT ALL PRIVILEGES ON discourse_development TO discourse;
psql> ALTER USER discourse WITH NOSUPERUSER;
gzip -d discourse.sql.gz
psql -U username -d discourse_development < discourse.sql #change username to your user name.
If all goes well, you will have a full working copy of your production site on your dev server:
Final Dev Touches
- Copy all your uploads in production to your dev server
- Set the Rails setting
force_https
to false - Turn off digests in your admin settings
Footnotes
-
After doing all the step above, I also copied over our production SendGrid settings, for fun and updated them in
./environments/development.rb
just so SMTP mail also works. -
You can also use the Ruby
mailcatcher
gem to catch all SMTP mail. -
Don't forget to clone any plugins in production over to dev that you might wish to run in dev
See Also:
https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-macos-for-development/15772/