PostgreSQL9.5 is the end of life now. You can use the steps mentioned in the below video to upgrade PostgreSQL9.5 to 12.
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install PostgreSQL9.5:
sudo yum install -y postgresql95-server
# Initialize the database and start service:
sudo /usr/pgsql-9.5/bin/postgresql95-setup initdb
# Install PostgreSQL12:
# Initialize the database and start service:
sudo yum install -y postgresql12-server
# PostgeSQL upgrade command syntax
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
# PostgeSQL Cluster compatibity check
pg_upgrade -b oldbindir -B newbindir -d oldconfigdir -D newconfigdir [option...]
/usr/pgsql-12/bin/pg_upgrade --old-bindir /usr/pgsql-9.5/bin/ --new-bindir /usr/pgsql-12/bin/ --old-datadir /var/lib/pgsql/9.5/data/ --new-datadir /var/lib/pgsql/12/data --link --check
# Upgrade Command
/usr/pgsql-12/bin/pg_upgrade --old-bindir /usr/pgsql-9.5/bin/ --new-bindir /usr/pgsql-12/bin/ --old-datadir /var/lib/pgsql/9.5/data/ --new-datadir /var/lib/pgsql/12/data --link