<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Manish Pradhan</title>
    <description>The latest articles on DEV Community by Manish Pradhan (@mangit007).</description>
    <link>https://dev.to/mangit007</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F611086%2F0d27e5cf-eacf-4b97-9d1d-3c7c303ecf83.jpeg</url>
      <title>DEV Community: Manish Pradhan</title>
      <link>https://dev.to/mangit007</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mangit007"/>
    <language>en</language>
    <item>
      <title>Maintaining Multiple Postgres Version</title>
      <dc:creator>Manish Pradhan</dc:creator>
      <pubDate>Fri, 09 Apr 2021 05:44:59 +0000</pubDate>
      <link>https://dev.to/younginnovations/maintaining-multiple-postgres-version-1h8n</link>
      <guid>https://dev.to/younginnovations/maintaining-multiple-postgres-version-1h8n</guid>
      <description>&lt;p&gt;Sometimes we need to have different Postgres versions in our local machine. We just need to know the port the versions are running and we are good to go.&lt;/p&gt;

&lt;p&gt;For this let's install two versions of Postgres 9.6 and 11 via commands&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Install Postgres 9.6&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install postgresql-9.6 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Install Postgres 11&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install postgresql-11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Lists the postgres clusters&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pg_lsclusters
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;start-stop the clusters&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo pg_ctlcluster 9.6 main start
sudo pg_ctlcluster 9.6 main stop
sudo pg_ctlcluster 11 main start
sudo pg_ctlcluster 11 main stop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;connects to 9.6&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo -i -u postgres psql -p 5432
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;connects to 11&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo -i -u postgres psql -p 5433
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By changing the port only we can restore and dump db according to postgres version&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;dumps and restores 9.6&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pg_dump --host localhost --port 5432 --username "postgres" --encoding UTF8 --verbose --file "{{db_backup_path}}" "{{db_name}}"
pg_restore --host 127.0.0.1 --port 5432 --username "postgres" --dbname "{{db_name}}" --verbose "{{db.backup}}"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;dumps and restores 11&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pg_dump --host localhost --port 5433 --username "postgres" --encoding UTF8 --verbose --file "{{db_backup_path}}" "{{db_name}}"
pg_restore --host 127.0.0.1 --port 5433 --username "postgres" --dbname "{{db_name}}" --verbose "{{db.backup}}"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>postgres</category>
      <category>database</category>
    </item>
  </channel>
</rss>
