How to upgrade postgresql database from 10 to 12 without losing data for openproject

前端 未结 3 811
醉梦人生
醉梦人生 2021-02-14 01:55

My OpenProject management software is installed with default postgresql 10. Currently the postgresql DB is 12, It is having lot of new features.

I want to upgrade my Pos

3条回答
  •  礼貌的吻别
    2021-02-14 02:27

    Postgresql Upgrade using pg_upgrade

    Step - 1 (Find the locale language and encoding of source Postgresql server)

    • Log in to Postgresql database as postgres user
    • Execute the query SHOW LC_COLLATE;

    Step - 2 ( Stop the existing/source Postgresql server)

    • Find the running Postgresql service using $ sudo systemctl list-units | grep postgres
    • Stop the service $ sudo service postgresql-.service stop

    Step - 3 (Install target Postgresql server)

    • Configure repos and install (lot of tutorials available in google)

    Step - 4 (Update the locale language and encoding)

    $ /usr/pgsql-/bin/initdb -D /var/lib/pgsql//data --locale=
    

    Step - 5 (Check the source to target upgrade has any potential issues)

    • Run the command as postgres user, $sudo su postgres
      $  /usr/pgsql-/bin/pg_upgrade --old-bindir /usr/pgsql-/bin --new-bindir /usr/pgsql-/bin --old-datadir /var/lib/pgsql//data --new-datadir /var/lib/pgsql/12/data --link --jobs=2 --check
    

    If it's ok we can move to the next step, If not fix the issues before proceeding to the next step Expected output: Clusters are compatible

    Step - 6 (Upgrade the source to target Postgresql version using the link option)

    • link option is pretty faster than the migration
    • Run the command as postgres user, $sudo su postgres
        $ /usr/pgsql-/bin/pg_upgrade --old-bindir /usr/pgsql-/bin --new-bindir /usr/pgsql-/bin --old-datadir /var/lib/pgsql//data --new-datadir /var/lib/pgsql//data --link
    

    Expected output: Upgrade Complete

    Thanks. ENJOY !!!

提交回复
热议问题