# Upgrading postgresql 9.5 to 12

**URL:** <https://forums.percona.com/t/upgrading-postgresql-9-5-to-12/16112>\
**Category:** PostgreSQL\
**Tags:** postgres, postgresql\
**Created:** [June 13, 2022, 10:02pm UTC](https://forums.percona.com/t/upgrading-postgresql-9-5-to-12/16112 "2022-06-13T22:02:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harshit\_Gupta](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/harshit_gupta/32/6735_2.png) [@Harshit\_Gupta](https://forums.percona.com/u/Harshit_Gupta)\
**Post date:** [June 13, 2022, 10:02pm UTC](https://forums.percona.com/t/upgrading-postgresql-9-5-to-12/16112/1 "2022-06-13T22:02:25Z")

</div>

Hi,  
We have a set of on premises servers which is currently running on PostgreSQL 9.5 and are having 10TB of data. We have 1 master and 4 slaves. What can be the most suitable approach for upgrade which causes minimum downtime?

Should we go for logical replication between 9.5 and 12 and do a DB flip  
or  
take downtime and do pg\_upgrade?

Regards,  
Harshit Gupta

---

<div class="post-metadata">

**Author:** ![Jobin\_Augustine](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/jobin_augustine/32/1275_2.png) [@Jobin\_Augustine](https://forums.percona.com/u/Jobin_Augustine)\
**Post date:** [June 14, 2022, 6:49am UTC](https://forums.percona.com/t/upgrading-postgresql-9-5-to-12/16112/2 "2022-06-14T06:49:31Z")

</div>

Hi Harshit,  
Upgrading using pg\_upgrade is the most common strategy. Mulit-terrabyte databases can be upgraded in a couple of minutes of downtime with hardlink option.  
you may please watch the demonstration video : [PostgreSQL Upgrade and Host Migration on Ubuntu - PostgreSQL migration tutorial - YouTube](https://www.youtube.com/watch?v=Ns_XmdMaHbk)  
If it is a critical environment, It will be a good idea to [hire an expert consultant](https://www.percona.com/services/consulting) who has done such upgrades in the past.  
Logical replication as you mentioned is also used of upgrades where direct pg\_upgrade is not possible. But it is overall more pain taking effort when it comes to big databases and heavy transaction systems.  
Regards,  
Jobin

---

<div class="post-metadata">

**Author:** ![Robert\_Bernier](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/robert_bernier/32/1367_2.png) [@Robert\_Bernier](https://forums.percona.com/u/Robert_Bernier)\
**Post date:** [June 14, 2022, 4:35pm UTC](https://forums.percona.com/t/upgrading-postgresql-9-5-to-12/16112/3 "2022-06-14T16:35:42Z")

</div>

One other note: What is less talked about is the ability to use rsync on the REPLICA in order to get the same speed that the hard link usage of pg\_upgrade. Refer to the postgres documentation for [pg\_upgrade](https://www.postgresql.org/docs/12/pgupgrade.html) and do a text search for rsync and you’ll see the reference. Needless to say you’ll need to practice this.
