User:Jtraulle/DiscourseMigration: Difference between revisions

Jump to navigation Jump to search
(Added Docker tips)
Tag: 2017 source edit
Line 461: Line 461:


1. Expose the 5432 TCP port from the container to the host by adding this line to the '''<code>expose:</code>''' section of <code>containers/app.yml</code> :
1. Expose the 5432 TCP port from the container to the host by adding this line to the '''<code>expose:</code>''' section of <code>containers/app.yml</code> :
<syntaxhighlight lang="yaml">
  - "5432:5432"
  - "5432:5432"
</syntaxhighlight>
2. Rebuild the container to take into account modifications to '''<code>app.yml</code>''' :
2. Rebuild the container to take into account modifications to '''<code>app.yml</code>''' :
<syntaxhighlight lang="bash">
  ./launcher rebuild app
  ./launcher rebuild app
</syntaxhighlight>
3. Enter into the container, login as the default postgresql user, add a new user and grant it all perms to the database
3. Enter into the container, login as the default postgresql user, add a new user and grant it all perms to the database
<syntaxhighlight lang="bash">
  ./launcher enter app
  ./launcher enter app
  sudo -u postgres psql discourse
  sudo -u postgres psql discourse
</syntaxhighlight>
<syntaxhighlight lang="sql">
  CREATE USER my_username WITH PASSWORD 'my_password';
  CREATE USER my_username WITH PASSWORD 'my_password';
  GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO my_username;
  GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO my_username;
Line 472: Line 479:
  GRANT ALL PRIVILEGES ON DATABASE discourse to my_username;
  GRANT ALL PRIVILEGES ON DATABASE discourse to my_username;
  \q
  \q
</syntaxhighlight>


Refer to [https://tableplus.io/blog/2018/04/postgresql-how-to-grant-access-to-users.html PostgreSQL - How to grant access to users?] for more info.
Refer to [https://tableplus.io/blog/2018/04/postgresql-how-to-grant-access-to-users.html PostgreSQL - How to grant access to users?] for more info.
Line 479: Line 487:
====Use <code>pg_dump</code> to dump the database====
====Use <code>pg_dump</code> to dump the database====


Below syntax assumed that a custom pgsql account has been created prior to running the command (following [[#Allow PostgreSQL to be accessed from an external application]] section instructions).
The command is executed from the host.
<syntaxhighlight lang="bash">
  pg_dump -h 127.0.0.1 -d discourse -U my_username -W > discourse-backup-20190801.sql
  pg_dump -h 127.0.0.1 -d discourse -U my_username -W > discourse-backup-20190801.sql
</syntaxhighlight>


====Use discourse internal backup tool====
====Use discourse internal backup tool====


It is also possible to use Discourse internal backup tool to grab a backup of the Discourse instance.
It is also possible to use Discourse internal backup tool to grab a backup (database + users uploads) of the Discourse instance.


Just go to <code>Admin → Backup</code>
Just go to <code>Admin → Backup</code>

Navigation menu