Skip to content
0:00 / 0:00

#postgresql#pgbackrest#replication

PostgreSQL primary and standby with pgbackrest backup complete step-by-step setup !

Automation Avenue

17K subscribers • 1 video on Hallway

YouTube
  • Recommended by 3 people: 3 in engineering communities.

Intermediate. Assumes working knowledge.

12K views2 years ago3 recommendations

Databases and dataCloud and DevOpsPostgres

A step-by-step tutorial on configuring a PostgreSQL primary and standby cluster with pgBackRest backups to AWS S3.

Step-by-step tutorial on how to configure Postgres / PostgreSQL cluster that includes primary ( master ) and standby ( slave / secondary ) server replicating from primary. We will then add PgBackRest that will be taking backups to remote location ( we will use AWS S3 bucket for that purpose, but PgBackrest allows you to choose any other storage you want ). Once we have that, we will perform various failover and recovery tasks to see how we can failover from primary to standby if primary PostgreSQL server goes down, and how to recover when both - primary and standby go down and we have to use PgBackrest and our remote backup to make the Postgres cluster back up and running again. We will be configuring PostgreSQL 16 on Ubuntu 24.04 LTS, but you can follow this tutorial for other Postgres versions and other linux distributions as the installation and configuration of Postgres doesnt differ much in other environments. This material is also available as Udemy training, please see the link below: udemy.com/course/postgresql-with-pgbackrest/?referralCode=2F… == TIMESTAMPS == What are we going to build Build and configure Ubuntu 24.04 servers for Postgresql 16 Postgres installation process Configuring pg_hba.conf Create database in postgresql Create primary and secondary database Configuring postgresql.conf file why we need to configure ‘listen addresses’ in postgresql.conf Further configuration of secondary postgres server pg_basebackup command explained and run Installing and configuring PgBackrest Create SSH connectivity between both servers Configuing pgbackrest.conf file Creating full postgres backup with pgbackrest command Failover from primary to secondary postgres database Recover postgres from remote location 🔥🔥 Learn Devops and Cloud on our platform: automation-avenue.com 📧 info@automation-avenue.com == 29 ==

Why it's here

3 people recommend this

What people say. Recommended as a comprehensive step-by-step guide to setting up PostgreSQL replication and pgBackRest backups.

u/ThickRanger5419in r/PostgreSQL • Recommends

On “Help me setup my first postgres server ”

You might consider self hosting on EC2 servers. It will be cheaper, but you will need to maintain it. Here is instruction how to configure PROD cluster with 2 servers and backup: link to this video

u/ThickRanger5419in r/PostgreSQL • Recommends

On “PostgreSQL on Ubuntu by Default”

They mean default repo, so you can install just by using 'sudo apt install postgrrsql' rather than building it from source. Have a look at this video that will show you full postgres installation and setup: link to this video

u/Lonely-Top-6349in r/PostgreSQL • Recommends

On “Advice on Postgres Backup strategy”

I'd go for pgbackrest solution, is more modern than barman and tested in battle. You have nice step-by-step configuration guide here: link to this video

u/ThickRanger5419in r/PostgreSQL • Recommends

On “PostgreSQL newbie questions”

This will dhow you how to set up production-like postgres infra in AWS: link to this video It uses S3 for backups

u/ThickRanger5419in r/PostgreSQL • Recommends

On “PostgreSQL Course with Practical Exercises (intermediate)”

I think its also worth to know how the cluster is initially configured in PROD if you want to be an expert, and this video goes through that process: link to this video

u/ThickRanger5419in r/PostgreSQL • Recommends

On “At what point should i switch to a managed service ?”

Not sure if that's what you are looking for, but thats how you set up production like postgres environment: link to this video 'Managed' will always mean 'more expensive', so it's really up to you to weight the difference...

u/KeyDecision2614in r/PostgreSQL • Recommends

On “Best way to create a PostgreSQL replica for disaster recovery (on-premise)?”

You might want to watch this video- it shows how to set up full PROD postgres environment including primary and standby server plus pgbackrest as backup solution: [video

u/KeyDecision2614in r/PostgreSQL • Mentions

On “does managing a database is that hard ?”

It's not that bad, even setting up a prod like infrastructure with primary,secondary and backup solution on a VPS is not THAT complicated. There is a good video going through that process: [video

u/KeyDecision2614in r/PostgreSQL • Mentions

On “What's the best practice for PostgreSQL database migration between on-premise servers?”

If you do not upgrade your postgres, then you just set up streaming replication with pg\_basebackup and failover. Its pretty easy, you can see how its done in this video (together with backup strategy) : [video If you want to upgrade the postgres itself, use pg\_logical replication, dump and restore or pg\_upgrade strategy.

u/KeyDecision2614in r/PostgreSQL • Mentions

On “Database level online backup tool”

pgbackrest is newer and better solution than barman. Here is a good guide on how to set it up: [video

u/KeyDecision2614in r/PostgreSQL • Mentions

On “Is it doable to run Postgres ourselves?”

Of course you can. This video shows EXACTLY the way we run our postgres PROD clusters with PgBackrest as our backup solution: [video Its fully managed by us and I kinda like the fact its not managed by cloud provider as managed solutions always have weird limitations...

u/ThickRanger5419in r/PostgreSQL • Mentions

On “At what point should i switch to a managed service ?”

I read OPs original post : ' when it comes to storage, they get expensive very quick'. So I am not sure why you say that. Regarding self-hosted postgres- I recommend this guide: link to this video