GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - anishnath/postgres: Video Demo

BranchesTags
Open more actions menu

Latest commit

 

History

7 Commits
7 Commits

Folders and files

NameName
Last commit message
Last commit date
README.md
README.md
 
 

Repository files navigation

postgres

Postgres PITR Backup & Restore Demo Configuration

Continuous Archiving and Point-in-Time Recovery (PITR)

Cick here for Video Demo https://youtu.be/WZps_MYYvV8

Postgres WAL Archiving

  1. Create the WAL & backup Directory and add necessary Permisson
bash~ mkdir -p  /var/lib/pgsql/wals/
bash~ mkdir -p  /var/lib/pgsql/backups/
bash~ chown postgres:postgres -R /var/lib/pgsql/backups/
bash~ chown postgres:postgres -R /var/lib/pgsql/wals/
  1. Edit the postgresql.conf with postgres user and add the below changes
wal_level=archive
archive_mode=on
archive_command = 'test ! -f /var/lib/pgsql/wals/%f && cp %p /var/lib/pgsql/wals/%f'
  1. Restart the database

bash~ service postgresql restart

  1. Prepare for the basebackup
su - postgres
psql -c "SELECT pg_start_backup('label');" postgres 
tar -C /var/lib/pgsql/data/ -czvf /var/lib/pgsql/backups/pg_basebackup_backup.tar.gz .
psql -c "SELECT pg_stop_backup();" postgres

Add Data to PostgreSQL

bash~  su - postgres
bash~  createdb mydb
bash~  psql -s mydb

Testing Restore

  1. Stop the postgres
bash~ /etc/init.d/postgresql stop
  1. Remove the data folder and Initilize the DB
bash~ cd /var/lib/pgsql/
bash~ rm -rf data/
  1. Initilaize the Database
bash~ /etc/init.d/postgresql initdb
bash~ /etc/init.d/postgresql start

Restore from WAL Archiving

  1. Stop the Postgres Server
bash~ /etc/init.d/postgresql stop
  1. Extract the Basebackup...
bash~  tar xvf /var/lib/pgsql/backups/pg_basebackup_backup.tar.gz -C /var/lib/pgsql/data
  1. Create recovery.conf with the below content and check the permission also
bash~ cd /var/lib/pgsql/data
bash~ cat recovery.conf 
restore_command = 'cp /var/lib/pgsql/wals/%f %p'
  1. Restart the Postgres DB
bash~ /etc/init.d/postgresql start
  1. Upon completion of the recovery process, the server will rename recovery.conf to recovery.done
bash~ cd /var/lib/pgsql/data
bash~ cat recover.done

About

Video Demo

youtu.be/WZps_MYYvV8

Topics

basebackupdatabasepitrpostgresrecoveryrestorewall

Resources

Readme
Activity

Stars

7 stars

Watchers

2 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.