Category Archives: PostgreSQL

Incremental backups in PostgreSQL 17

Incremental Backups in PostgreSQL 17

Table of Contents



1. WAL Summarization (Similar to Oracle Block Change Tracking)

PostgreSQL 17 introduces a background process called the walsummarizer, which tracks which blocks in data files have changed over ranges of WAL (Write Ahead Log) records.
This feature enables efficient incremental backups by identifying only the blocks changed since the previous backup.
WAL summaries are stored in: PGDATA/pg_wal/summaries/

New Configuration Settings:
1. summarize_wal (boolean) – Enables or disables the summarizer. Default: off.
2. wal_summary_keep_time – Duration to retain summary files. Default: 10 days.

2. Incremental File System Backups with pg_basebackup

-- PostgreSQL 17 adds an --incremental option to pg_basebackup.
-- When WAL summarization is enabled, you can create backups that include only the changed blocks since the previous full or incremental backup.
-- A new utility (e.g., pg_combinebackup) is used to merge full and incremental backups during restoration.

3. New Functions and Utilities for WAL Summarization

 	pg_available_wal_summaries()
 	pg_wal_summary_contents()
 	pg_get_wal_summarizer_state()

Tool: pg_walsummary — A CLI utility to inspect WAL summary files.

4. How to Enable and Use summarize_wal

4.1. Check Current Status

postgres=# SHOW summarize_wal;
 summarize_wal
---------------
 off
(1 row)

postgres=#

[postgres@lxicbpgdsgv01 ~]$ ps -ef | grep postgres
postgres    1390       1  0 12:15 ?        00:00:00 /usr/pgsql-17/bin/postgres -D /pgData/pgsql17/data/
postgres    1456    1390  0 12:15 ?        00:00:00 postgres: logger
postgres    1466    1390  0 12:15 ?        00:00:00 postgres: checkpointer
postgres    1467    1390  0 12:15 ?        00:00:00 postgres: background writer
postgres    1479    1390  0 12:15 ?        00:00:00 postgres: walwriter
postgres    1480    1390  0 12:15 ?        00:00:00 postgres: autovacuum launcher
postgres    1481    1390  0 12:15 ?        00:00:00 postgres: archiver
postgres    1484    1390  0 12:15 ?        00:00:00 postgres: logical replication launcher
root        3205    3150  0 12:48 pts/0    00:00:00 su - postgres
postgres    3212    3205  0 12:48 pts/0    00:00:00 -bash
postgres    3290    3212 99 12:49 pts/0    00:00:00 ps -ef
postgres    3291    3212  0 12:49 pts/0    00:00:00 grep --color=auto postgres
[postgres@lxicbpgdsgv01 ~]$

	  

4.2. Enable WAL Summarization

postgres=# ALTER SYSTEM SET summarize_wal = 'on';
ALTER SYSTEM
postgres=#

4.3. Reload PostgreSQL Configuration

postgres=# SELECT pg_reload_conf();
 pg_reload_conf
----------------
 t
(1 row)

postgres=#
	  

4.4. Confirm summarize_wal is Enabled

postgres=# SHOW summarize_wal;
 summarize_wal
---------------
 on <----
(1 row)

postgres=#

[postgres@lxicbpgdsgv01 ~]$ ps -ef | grep postgres
postgres    1390       1  0 12:15 ?        00:00:00 /usr/pgsql-17/bin/postgres -D /pgData/pgsql17/data/
postgres    1456    1390  0 12:15 ?        00:00:00 postgres: logger
postgres    1466    1390  0 12:15 ?        00:00:00 postgres: checkpointer
postgres    1467    1390  0 12:15 ?        00:00:00 postgres: background writer
postgres    1479    1390  0 12:15 ?        00:00:00 postgres: walwriter
postgres    1480    1390  0 12:15 ?        00:00:00 postgres: autovacuum launcher
postgres    1481    1390  0 12:15 ?        00:00:00 postgres: archiver
postgres    1484    1390  0 12:15 ?        00:00:00 postgres: logical replication launcher
root        3205    3150  0 12:48 pts/0    00:00:00 su - postgres
postgres    3212    3205  0 12:48 pts/0    00:00:00 -bash
postgres    3445    1390  0 12:51 ?        00:00:00 postgres: walsummarizer <-------
postgres    3537    3212  0 12:53 pts/0    00:00:00 ps -ef
postgres    3538    3212  0 12:53 pts/0    00:00:00 grep --color=auto postgres
[postgres@lxicbpgdsgv01 ~]$

4.5. List Available WAL Summaries (Ordered by Start LSN)

postgres=# SELECT * FROM pg_available_wal_summaries() ORDER BY start_lsn;
 tli | start_lsn  |  end_lsn
-----+------------+------------
   1 | 0/95000028 | 0/9501BA38
   1 | 0/9501BA38 | 0/96000028
(2 rows)

postgres=#

postgres=# select pg_get_wal_summarizer_state();
  pg_get_wal_summarizer_state
--------------------------------
 (1,0/96000028,0/960000A0,3445)
(1 row)

postgres=#

postgres=# SELECT * FROM pg_available_wal_summaries() LIMIT 1;
 tli | start_lsn  |  end_lsn
-----+------------+------------
   1 | 0/95000028 | 0/9501BA38
(1 row)

postgres=#

postgres=# SELECT * FROM pg_wal_summary_contents(1, '0/95000028', '0/9501BA38');
 relfilenode | reltablespace | reldatabase | relforknumber | relblocknumber | is_limit_block
-------------+---------------+-------------+---------------+----------------+----------------
        1247 |         16542 |       16544 |             0 |             14 | f
        1249 |         16542 |       16544 |             0 |             54 | f
        1249 |         16542 |       16544 |             0 |             55 | f
        1259 |         16542 |       16544 |             0 |              1 | f
        2608 |         16542 |       16544 |             0 |             12 | f
        2610 |         16542 |       16544 |             0 |              1 | f
        2658 |         16542 |       16544 |             0 |             15 | f
        2659 |         16542 |       16544 |             0 |             10 | f
        2662 |         16542 |       16544 |             0 |              2 | f
        2663 |         16542 |       16544 |             0 |              1 | f
        2663 |         16542 |       16544 |             0 |              2 | f
        2673 |         16542 |       16544 |             0 |              4 | f
        2673 |         16542 |       16544 |             0 |              9 | f
        2674 |         16542 |       16544 |             0 |              7 | f
        2674 |         16542 |       16544 |             0 |              5 | f
        2678 |         16542 |       16544 |             0 |              1 | f
        2679 |         16542 |       16544 |             0 |              1 | f
        2703 |         16542 |       16544 |             0 |              2 | f
        2704 |         16542 |       16544 |             0 |              4 | f
        2704 |         16542 |       16544 |             0 |              1 | f
        3455 |         16542 |       16544 |             0 |              1 | f
       16558 |         16542 |       16544 |             0 |              0 | t
       16558 |         16542 |       16544 |             0 |              0 | f
       16561 |         16542 |       16544 |             0 |              0 | t
       16562 |         16542 |       16544 |             0 |              0 | t
       16562 |         16542 |       16544 |             0 |              0 | f
(26 rows)

postgres=#
	  

5. Weekly Backup Strategy (PostgreSQL 17 / Oracle Style)

DayBackup TypeDescriptionBased On
SundayFull Backup (Level 0)Copies the entire database — all datafiles (similar to Oracle Level 0 backups).
MondayIncremental BackupBacks up only datafile blocks changed since Sunday’s full backup.Sunday’s backup_manifest
TuesdayIncremental BackupBacks up only blocks changed since Monday’s incremental backup.Monday’s backup_manifest
WednesdayIncremental BackupBacks up only blocks changed since Tuesday’s incremental backup.Tuesday’s backup_manifest
ThursdayIncremental BackupBacks up only blocks changed since Wednesday’s incremental backup.Wednesday’s backup_manifest
FridayIncremental BackupBacks up only blocks changed since Thursday’s incremental backup.Thursday’s backup_manifest
SaturdayIncremental BackupBacks up only blocks changed since Friday’s incremental backup.Friday’s backup_manifest
 
# Sunday - Full backup
nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/Sun_Full -l "This is Sunday Full backup (Level 0)" -Ft -Xs -P -v > /pgBackup/pgsql17/backup/log/Sunday_Full.log 2>&1 &

# Monday - Incremental based on Sunday full
nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/Mon_Incr -l "This is Monday Incremental (Level 1)" -i /pgBackup/pgsql17/backup/Sun_Full/backup_manifest -Ft -Xs -P -v > /pgBackup/pgsql17/backup/log/Mon_Incr.log 2>&1 &

# Tuesday - Incremental based on Monday incremental
nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/Tue_Incr -l "This is Tuesday Incremental (Level 1)" -i /pgBackup/pgsql17/backup/Mon_Incr/backup_manifest -Ft -Xs -P -v > /pgBackup/pgsql17/backup/log/Tue_Incr.log 2>&1 &

# Wednesday - Incremental based on Tuesday incremental
nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/Wed_Incr -l "This is Wednesday Incremental (Level 1)" -i /pgBackup/pgsql17/backup/Tue_Incr/backup_manifest -Ft -Xs -P -v > /pgBackup/pgsql17/backup/log/Wed_Incr.log 2>&1 &

# Thursday - Incremental based on Wednesday incremental
nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/Thu_Incr -l "This is Thursday Cumulative" -i /pgBackup/pgsql17/backup/Wed_Incr/backup_manifest -Ft -Xs -P -v > /pgBackup/pgsql17/backup/log/Thu_Incr.log 2>&1 &

# Friday - Incremental based on Thursday incremental
nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/Fri_Incr -l "This is Friday Incremental (Level 1)" -i /pgBackup/pgsql17/backup/Thu_Incr/backup_manifest -Ft -Xs -P -v > /pgBackup/pgsql17/backup/log/Fri_Incr.log 2>&1 &

# Saturday - Incremental based on Friday incremental
nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/Sat_Incr -l "This is Saturday Incremental (Level 1)" -i /pgBackup/pgsql17/backup/Fri_Incr/backup_manifest -Ft -Xs -P -v > /pgBackup/pgsql17/backup/log/Sat_Incr.log 2>&1 &

6. Restore Incremental Path

A new utility (e.g., pg_combinebackup) is used to merge full and incremental backups during restoration.

To restore the full database as of Saturday, apply these backups in sequence:

  • Sunday (Full Backup)
  • Monday (Incremental)
  • Tuesday (Incremental)
  • Wednesday (Incremental)
  • Thursday (Incremental)
  • Friday (Incremental)
  • Saturday (Incremental)
# Incremental Restore Path
# Combine all backups to single directory /pgBackup/pgsql17/backup/combined_full_backup

# Extract first using tar command

for dir in Sun_Full Mon_Incr Tue_Incr Wed_Incr Thu_Incr Fri_Incr Sat_Incr
do
echo "Extracting in $dir ..."
cd /pgBackup/pgsql17/backup/$dir || continue
for f in *.tar; do
tar -xf "$f"
done
done

[postgres@lxicbpgdsgv01 ~]$ for dir in Sun_Full Mon_Incr Tue_Incr Wed_Incr Thu_Incr Fri_Incr Sat_Incr
do
echo "Extracting in $dir ..."
cd /pgBackup/pgsql17/backup/$dir || continue
for f in *.tar; do
tar -xf "$f"
done
done
Extracting in Sun_Full ...
tar: pg_stat: time stamp 2025-10-13 20:15:19 is 13627.701332157 s in the future
Extracting in Mon_Incr ...
tar: pg_stat: time stamp 2025-10-13 20:15:19 is 13627.308655658 s in the future
Extracting in Tue_Incr ...
tar: pg_stat: time stamp 2025-10-13 20:15:19 is 13626.906480756 s in the future
Extracting in Wed_Incr ...
tar: pg_stat: time stamp 2025-10-13 20:15:19 is 13626.534470296 s in the future
Extracting in Thu_Incr ...
tar: pg_stat: time stamp 2025-10-13 20:15:19 is 13626.217307586 s in the future
Extracting in Fri_Incr ...
tar: pg_stat: time stamp 2025-10-13 20:15:19 is 13626.03629929 s in the future
Extracting in Sat_Incr ...
tar: pg_stat: time stamp 2025-10-13 20:15:19 is 13625.670340241 s in the future
[postgres@lxicbpgdsgv01 Sat_Incr]$

# Combine backup to /pgBackup/pgsql17/backup/combined_full_backup

nohup pg_combinebackup /pgBackup/pgsql17/backup/Sun_Full \
/pgBackup/pgsql17/backup/Mon_Incr \
/pgBackup/pgsql17/backup/Tue_Incr \
/pgBackup/pgsql17/backup/Wed_Incr \
/pgBackup/pgsql17/backup/Thu_Incr \
/pgBackup/pgsql17/backup/Fri_Incr \
/pgBackup/pgsql17/backup/Sat_Incr \
-o /pgBackup/pgsql17/backup/combined_full_backup \
> /pgBackup/pgsql17/backup/log/restore_incremental.log 2>&1 &

[postgres@lxicbpgdsgv01 ~]$ ls -ltr /pgBackup/pgsql17/backup/combined_full_backup
total 39296
-rw-------. 1 postgres postgres 240 Oct 13 16:29 backup_label
-rw-------. 1 postgres postgres 1174528 Oct 13 16:29 16542.tar
-rw-------. 1 postgres postgres 16778752 Oct 13 16:29 pg_wal.tar
-rw-------. 1 postgres postgres 1171968 Oct 13 16:29 16545.tar
-rw-------. 1 postgres postgres 4002816 Oct 13 16:29 base.tar
drwx------. 4 postgres postgres 32 Oct 13 16:29 PG_17_202406281
-rw-------. 1 postgres postgres 68 Oct 13 16:29 tablespace_map
drwx------. 5 postgres postgres 33 Oct 13 16:29 base
drwx------. 2 postgres postgres 4096 Oct 13 16:29 global
drwx------. 2 postgres postgres 188 Oct 13 16:29 log
-rw-------. 1 postgres postgres 5600 Oct 13 16:29 pg_hba.conf
drwx------. 2 postgres postgres 6 Oct 13 16:29 pg_dynshmem
drwx------. 2 postgres postgres 6 Oct 13 16:29 pg_commit_ts
drwx------. 4 postgres postgres 68 Oct 13 16:29 pg_logical
-rw-------. 1 postgres postgres 2640 Oct 13 16:29 pg_ident.conf
drwx------. 4 postgres postgres 36 Oct 13 16:29 pg_multixact
drwx------. 2 postgres postgres 6 Oct 13 16:29 pg_twophase
drwx------. 2 postgres postgres 6 Oct 13 16:29 pg_tblspc
drwx------. 2 postgres postgres 6 Oct 13 16:29 pg_subtrans
drwx------. 2 postgres postgres 6 Oct 13 16:29 pg_stat_tmp
drwx------. 2 postgres postgres 6 Oct 13 16:29 pg_stat
drwx------. 2 postgres postgres 6 Oct 13 16:29 pg_snapshots
drwx------. 2 postgres postgres 6 Oct 13 16:29 pg_serial
drwx------. 2 postgres postgres 6 Oct 13 16:29 pg_replslot
drwx------. 2 postgres postgres 6 Oct 13 16:29 pg_notify
drwx------. 2 postgres postgres 18 Oct 13 16:29 pg_xact
-rw-------. 1 postgres postgres 3 Oct 13 16:29 PG_VERSION
-rw-------. 1 postgres postgres 1169 Oct 13 16:29 postgresql.conf.bkp_10sep2025
-rw-------. 1 postgres postgres 30702 Oct 13 16:29 postgresql.conf.bkp
-rw-------. 1 postgres postgres 109 Oct 13 16:29 postgresql.auto.conf
drwx------. 4 postgres postgres 45 Oct 13 16:29 pg_wal
-rw-------. 1 postgres postgres 1169 Oct 13 16:29 postgresql.conf
-rw-------. 1 postgres postgres 30 Oct 13 16:29 current_logfiles
-rw-------. 1 postgres postgres 227 Oct 13 16:29 backup_label.old
-rw-------. 1 postgres postgres 16777216 Oct 13 16:29 0000000100000000000000B2
-rw-------. 1 postgres postgres 238882 Oct 13 16:29 backup_manifest
[postgres@lxicbpgdsgv01 ~]$

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

PostgreSQL Point-in-Time Recovery (PITR)

PostgreSQL PITR: How to Restore & Recover to a Specific Point in Time

Table of Contents



0. Goal

Scenario: Application team deleted critical data at 2025-10-12 22:05:29 PM.

Action: Recover database to 2025-10-12 22:05:00 PM using base backup and WAL archives. 
---> Restore and recover on other server
---> Take backup of table
---> Restore the table back.

1. Environment (Source / Target)

AspectSourceTargetDifference
Hostnamelxicbpgdsgv01lxicbpgdsgv02Different hostnames
IP Address192.168.2.51192.168.2.52Different IPs
OSRHEL 9RHEL 9Same
DB VersionPostgreSQL v17.6PostgreSQL v17.6Same
Archive modearchive_mode=onarchive_mode=onSame
PGDATA/pgData/pgsql17/data/pgdata/pgsql17/dataDifferent path case (D vs d)
WAL Directory/pgWal/pgsql17/wal/pgwal/pgsql17/walDifferent path case (W vs w)
WAL Archive Directory/pgArch/pgsql17/arch/pgarchive/pgsql17/archiveDifferent path case (W vs w)
Backup Directory/pgBackup/pgsql17/backup/pgbackup/pgsql17/backupDifferent path case (B vs b)
restore_commandNot Applicable/pgbackup/pgsql17/backup/archive_bkp12OCT2025restore_command on target server for full recovery
recovery_target_timeTable dropped at2025-10-12 22:05:29Recover until time 2025-10-12 22:05:00recovery_target_time on target server for PITR
Tablespace & PathDELL_TB_DATA:/pgTb/pgsql17/tbs/delltbs01, ORCL_TB_DATA:/pgTb/pgsql17/tbs/orcltbs01DELL_TB_DATA:/pgtsdata01/pgsql17/tbs/delltbs01, ORCL_TB_DATA:/pgtsdata01/pgsql17/tbs/orcltbs01It will restore using the same tablespace names, but at different locations.
DatabasesDELL, ORCLWe will restore both from backupWe will restore both

2. Verify Existing DB Setup

[postgres@lxicbpgdsgv01 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# \l+
                                                                                        List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | Locale | ICU Rules |   Access privileges   |  Size   |  Tablespace  |                Description
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------+---------+--------------+--------------------------------------------
 dell      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7755 kB | dell_tb_data |
 orcl      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7569 kB | orcl_tb_data |
 postgres  | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 492 MB  | pg_default   | default administrative connection database
 template0 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7545 kB | pg_default   | unmodifiable empty database
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |              |
 template1 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7569 kB | pg_default   | default template for new databases
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |              |
(5 rows)

postgres=# \db
                  List of tablespaces
     Name     |  Owner   |          Location
--------------+----------+-----------------------------
 dell_tb_data | postgres | /pgTb/pgsql17/tbs/delltbs01
 orcl_tb_data | postgres | /pgTb/pgsql17/tbs/orcltbs01
 pg_default   | postgres |
 pg_global    | postgres |
(4 rows)

postgres=#

postgres=# \c dell
You are now connected to database "dell" as user "postgres".
dell=# select * from test.emp;
 name | designation | project | company
------+-------------+---------+---------
 Sugi | DBA         | Jetstar | iGATE
 Teja | DBA         | RCM     | iGATE
 RAJ  | DBA         | RCM     | iGATE
 KK   | DBA LEAD    | RCM     | iGATE
(4 rows)

dell=#

3. Pre-requisites

3.1. Verify postgresql.conf

postgres=# SHOW wal_level;
 wal_level
-----------
 replica
(1 row)

postgres=# show archive_mode;
 archive_mode
--------------
 on
(1 row)

postgres=# show archive_command;
        archive_command
-------------------------------
 cp %p /pgArch/pgsql17/arch/%f
(1 row)

postgres=#

3.2. Verify pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS             METHOD
# Local connections for replication (for pg_basebackup run locally)
local   replication     all                                 trust

# Remote connections for replication (for pg_basebackup run remotely)
#host    replication     repl_user       192.168.2.52/32     scram-sha-256

3.3. Verify User Permissions (REPLICATION or SUPERUSER)

postgres=# \du
                             List of roles
 Role name |                         Attributes
-----------+------------------------------------------------------------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS

postgres=#

3.4. Verify Free Space for Backup

[postgres@lxicbpgdsgv01 ~]$ df -h /pgBackup
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdd1       100G  746M  100G   1% /pgBackup
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ mkdir -p /pgBackup/pgsql17/backup/base_bkp12OCT2025
[postgres@lxicbpgdsgv01 ~]$ mkdir -p /pgBackup/pgsql17/backup/archive_bkp12OCT2025
[postgres@lxicbpgdsgv01 ~]$

4. Take Base Backup and WAL Archive

4.1. Take Base Backup

[postgres@lxicbpgdsgv01 ~]$ nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/base_bkp12OCT2025 -Ft -Xs -P -v > /pgBackup/pgsql17/backup/base_bkp12OCT2025.log 2>&1 &
[1] 3347
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ cat /pgBackup/pgsql17/backup/base_bkp12OCT2025.log
nohup: ignoring input
pg_basebackup: initiating base backup, waiting for checkpoint to complete
pg_basebackup: checkpoint completed
pg_basebackup: write-ahead log start point: 0/91000028 on timeline 1
pg_basebackup: starting background WAL receiver
pg_basebackup: created temporary replication slot "pg_basebackup_3350"
  7754/535860 kB (1%), 0/3 tablespaces (...ckup/base_bkp12OCT2025/16542.tar)
  7754/535860 kB (1%), 1/3 tablespaces (...ckup/base_bkp12OCT2025/16542.tar)
 15474/535860 kB (2%), 1/3 tablespaces (...ckup/base_bkp12OCT2025/16545.tar)
 15474/535860 kB (2%), 2/3 tablespaces (...ckup/base_bkp12OCT2025/16545.tar)
191400/535860 kB (35%), 2/3 tablespaces (...ackup/base_bkp12OCT2025/base.tar)
372072/535860 kB (69%), 2/3 tablespaces (...ackup/base_bkp12OCT2025/base.tar)
525644/535860 kB (98%), 2/3 tablespaces (...ackup/base_bkp12OCT2025/base.tar)
535873/535873 kB (100%), 2/3 tablespaces (...ackup/base_bkp12OCT2025/base.tar)
535873/535873 kB (100%), 3/3 tablespaces
pg_basebackup: write-ahead log end point: 0/91000120
pg_basebackup: waiting for background process to finish streaming ...
pg_basebackup: syncing data to disk ...
pg_basebackup: renaming backup_manifest.tmp to backup_manifest
pg_basebackup: base backup completed <----
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ du -sh /pgBackup/pgsql17/backup/base_bkp12OCT2025
540M    /pgBackup/pgsql17/backup/base_bkp12OCT2025
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ ls -ltr /pgBackup/pgsql17/backup/base_bkp12OCT2025
total 552508
-rw-------. 1 postgres postgres   7940096 Oct 12 21:57 16542.tar
-rw-------. 1 postgres postgres   7905792 Oct 12 21:57 16545.tar
-rw-------. 1 postgres postgres 532888576 Oct 12 21:57 base.tar
-rw-------. 1 postgres postgres    243763 Oct 12 21:57 backup_manifest
-rw-------. 1 postgres postgres  16778752 Oct 12 21:57 pg_wal.tar
[postgres@lxicbpgdsgv01 ~]$

4.2. Insert new row on table test.emp

postgres=# \c dell
You are now connected to database "dell" as user "postgres".
dell=# INSERT INTO test.emp VALUES ('DEV', 'DBA MANAGER', 'RCM', 'iGATE');
INSERT 0 1
dell=# CHECKPOINT;
CHECKPOINT
dell=# SELECT * FROM TEST.EMP;
 name | designation | project | company
------+-------------+---------+---------
 Sugi | DBA         | Jetstar | iGATE
 Teja | DBA         | RCM     | iGATE
 RAJ  | DBA         | RCM     | iGATE
 KK   | DBA LEAD    | RCM     | iGATE
 DEV  | DBA MANAGER | RCM     | iGATE <-- New row 
(5 rows)

dell=# SELECT NOW();
              now
-------------------------------
 2025-10-12 22:04:29.793434+08
(1 row)

dell=#

dell=# SELECT pg_switch_wal();
 pg_switch_wal
---------------
 0/92000298
(1 row)

dell=# SELECT pg_switch_wal();
 pg_switch_wal
---------------
 0/93000000
(1 row)

dell=#

4.3. Dropped table test.emp accidentally


dell=# SELECT NOW();
              now
-------------------------------
 2025-10-12 22:05:29.954216+08 <----
(1 row)

dell=# DROP TABLE TEST.EMP; <-----
DROP TABLE
dell=# SELECT NOW();
              now
-------------------------------
 2025-10-12 22:05:42.890468+08
(1 row)

dell=#
dell=# SELECT pg_switch_wal();
 pg_switch_wal
---------------
 0/93007FF0
(1 row)

dell=# SELECT pg_switch_wal();
 pg_switch_wal
---------------
 0/94000000
(1 row)

dell=#

5. Transfer Base Backup and WAL Archives to Target


# Copy WAL Archive Fils 

[postgres@lxicbpgdsgv01 ~]$ cp /pgArch/pgsql17/arch/* /pgBackup/pgsql17/backup/archive_bkp12OCT2025
[postgres@lxicbpgdsgv01 ~]$ 

[postgres@lxicbpgdsgv01 backup]$ tar -cvf base_bkp12OCT2025.tar base_bkp12OCT2025
base_bkp12OCT2025/
base_bkp12OCT2025/16542.tar
base_bkp12OCT2025/pg_wal.tar
base_bkp12OCT2025/16545.tar
base_bkp12OCT2025/base.tar
base_bkp12OCT2025/backup_manifest
[postgres@lxicbpgdsgv01 backup]$
[postgres@lxicbpgdsgv01 backup]$ tar -cvf archive_bkp12OCT2025.tar archive_bkp12OCT2025
archive_bkp12OCT2025/
archive_bkp12OCT2025/00000001000000000000008E
archive_bkp12OCT2025/00000001000000000000008F
archive_bkp12OCT2025/000000010000000000000090
archive_bkp12OCT2025/000000010000000000000091
archive_bkp12OCT2025/000000010000000000000091.00000028.backup
archive_bkp12OCT2025/000000010000000000000092
archive_bkp12OCT2025/000000010000000000000093
[postgres@lxicbpgdsgv01 backup]$ pwd
/pgBackup/pgsql17/backup
[postgres@lxicbpgdsgv01 backup]$
[postgres@lxicbpgdsgv01 backup]$ ls -ltr
total 650832
drwxr-xr-x. 2 postgres postgres        97 Oct 12 21:57 base_bkp12OCT2025
-rw-r--r--. 1 postgres postgres      1286 Oct 12 21:57 base_bkp12OCT2025.log
drwxr-xr-x. 2 postgres postgres      4096 Oct 12 22:13 archive_bkp12OCT2025
-rw-r--r--. 1 postgres postgres 565770240 Oct 12 22:36 base_bkp12OCT2025.tar  <--- 
-rw-r--r--. 1 postgres postgres 100669440 Oct 12 22:36 archive_bkp12OCT2025.tar <--- 
[postgres@lxicbpgdsgv01 backup]$

[postgres@lxicbpgdsgv01 backup]$ scp *.tar 192.168.2.52:/pgbackup/pgsql17/backup
postgres@192.168.2.52's password:
archive_bkp12OCT2025.tar                   100%   96MB  61.0MB/s   00:01
base_bkp12OCT2025.tar                      100%  540MB  67.0MB/s   00:08
[postgres@lxicbpgdsgv01 backup]$

6. Check and Prepare Target Environment

6.1. Check Existing symbolic link and Mounts

[postgres@lxicbpgdsgv02 ~]$ find /pgdata/pgsql17/data -type l -ls
134356985      0 lrwxrwxrwx   1 postgres postgres       18 Oct 12 01:50 /pgdata/pgsql17/data/pg_wal -> /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$

6.2. Create Tablespace Directories

[postgres@lxicbpgdsgv02 ~]$ mkdir -p /pgtsdata01/pgsql17/tbs/delltbs01
[postgres@lxicbpgdsgv02 ~]$ mkdir -p /pgtsdata01/pgsql17/tbs/orcltbs01
[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgtsdata01/pgsql17/tbs/delltbs01
[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgtsdata01/pgsql17/tbs/orcltbs01
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgtsdata01/pgsql17/tbs/delltbs01
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgtsdata01/pgsql17/tbs/orcltbs01
[postgres@lxicbpgdsgv02 ~]$

6.3. Stop PostgreSQL

[root@lxicbpgdsgv02 ~]# systemctl stop postgresql-17.service
[root@lxicbpgdsgv02 ~]# ps -ef | grep pmon
root        3529    3228  0 23:50 pts/0    00:00:00 grep --color=auto pmon
[root@lxicbpgdsgv02 ~]#

6.4. Clean Data, WAL, and Archive Directories

# Please ensure a backup is taken, if needed, before deleting the contents.
# Remove $PGDATA contents
[postgres@lxicbpgdsgv02 ~]$ rm -rf /pgdata/pgsql17/data/*
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data
total 0
[postgres@lxicbpgdsgv02 ~]$

# Remove WAL log files (Redo log files)
[postgres@lxicbpgdsgv02 ~]$ rm -rf /pgwal/pgsql17/wal/*
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgwal/pgsql17/wal
total 0
[postgres@lxicbpgdsgv02 ~]$

# Remove WAL Archive log files 
[postgres@lxicbpgdsgv02 ~]$ rm -rf /pgarchive/pgsql17/archive/*
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgarchive/pgsql17/archive
total 0
[postgres@lxicbpgdsgv02 ~]$

7. Restore Backup on Target

7.1. Extract Backup Files

[postgres@lxicbpgdsgv02 ~]$ cd /pgbackup/pgsql17/backup
[postgres@lxicbpgdsgv02 backup]$ ls -ltr
total 650824
-rw-r--r--. 1 postgres postgres 100669440 Oct 12 22:38 archive_bkp12OCT2025.tar
-rw-r--r--. 1 postgres postgres 565770240 Oct 12 22:38 base_bkp12OCT2025.tar
[postgres@lxicbpgdsgv02 backup]$
[postgres@lxicbpgdsgv02 backup]$ tar -xvf base_bkp12OCT2025.tar
base_bkp12OCT2025/
base_bkp12OCT2025/16542.tar
base_bkp12OCT2025/pg_wal.tar
base_bkp12OCT2025/16545.tar
base_bkp12OCT2025/base.tar
base_bkp12OCT2025/backup_manifest
[postgres@lxicbpgdsgv02 backup]$
[postgres@lxicbpgdsgv02 backup]$ ls -ltr
total 650824
drwxr-xr-x. 2 postgres postgres        97 Oct 12 21:57 base_bkp12OCT2025
-rw-r--r--. 1 postgres postgres 100669440 Oct 12 22:38 archive_bkp12OCT2025.tar
-rw-r--r--. 1 postgres postgres 565770240 Oct 12 22:38 base_bkp12OCT2025.tar
[postgres@lxicbpgdsgv02 backup]$ cd base_bkp12OCT2025/
[postgres@lxicbpgdsgv02 base_bkp12OCT2025]$ ls -ltr
total 552508
-rw-------. 1 postgres postgres   7905792 Oct 12 21:57 16545.tar
-rw-------. 1 postgres postgres   7940096 Oct 12 21:57 16542.tar
-rw-------. 1 postgres postgres  16778752 Oct 12 21:57 pg_wal.tar
-rw-------. 1 postgres postgres 532888576 Oct 12 21:57 base.tar
-rw-------. 1 postgres postgres    243763 Oct 12 21:57 backup_manifest
[postgres@lxicbpgdsgv02 base_bkp12OCT2025]$

7.2. Restore Base Data Directory

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/
total 0
[postgres@lxicbpgdsgv02 ~]$ nohup tar -xvf /pgbackup/pgsql17/backup/base_bkp12OCT2025/base.tar -C /pgdata/pgsql17/data > /pgbackup/pgsql17/backup/base_restore.log 2>&1 &
[1] 3607
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/
total 80
-rw-------. 1 postgres postgres   227 Oct 10 18:41 backup_label.old
-rw-------. 1 postgres postgres  1169 Oct 10 18:41 postgresql.conf.bkp_10sep2025
-rw-------. 1 postgres postgres 30702 Oct 10 18:41 postgresql.conf.bkp
-rw-------. 1 postgres postgres    88 Oct 10 18:41 postgresql.auto.conf
drwx------. 2 postgres postgres    18 Oct 10 18:41 pg_xact
-rw-------. 1 postgres postgres     3 Oct 10 18:41 PG_VERSION
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_twophase
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_stat_tmp
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_snapshots
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_serial
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_notify
drwx------. 4 postgres postgres    36 Oct 10 18:41 pg_multixact
-rw-------. 1 postgres postgres  2640 Oct 10 18:41 pg_ident.conf
-rw-------. 1 postgres postgres  5600 Oct 10 18:41 pg_hba.conf
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_dynshmem
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_commit_ts
drwx------. 2 postgres postgres     6 Oct 10 19:45 pg_subtrans
-rw-------. 1 postgres postgres  1169 Oct 11 02:42 postgresql.conf
drwx------. 2 postgres postgres     6 Oct 11 02:57 pg_tblspc
drwx------. 5 postgres postgres    33 Oct 11 03:01 base
drwx------. 4 postgres postgres    68 Oct 12 21:57 pg_logical
-rw-------. 1 postgres postgres    68 Oct 12 21:57 tablespace_map
drwx------. 2 postgres postgres     6 Oct 12 21:57 pg_replslot
-rw-------. 1 postgres postgres   227 Oct 12 21:57 backup_label
drwx------. 2 postgres postgres     6 Oct 12 23:17 pg_stat
drwx------. 4 postgres postgres    45 Oct 12 23:53 pg_wal
drwx------. 2 postgres postgres  4096 Oct 12 23:53 global
drwx------. 2 postgres postgres   188 Oct 13  2025 log
-rw-------. 1 postgres postgres    30 Oct 13  2025 current_logfiles
[postgres@lxicbpgdsgv02 ~]$

7.3. Restore WAL Directory

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgwal/pgsql17/wal/
total 0
[postgres@lxicbpgdsgv02 ~]$ nohup tar -xvf /pgbackup/pgsql17/backup/base_bkp12OCT2025/pg_wal.tar -C /pgwal/pgsql17/wal > /pgbackup/pgsql17/backup/wal_restore.log 2>&1 &
[1] 3610
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgwal/pgsql17/wal/
total 16384
-rw-------. 1 postgres postgres 16777216 Oct 12 21:57 000000010000000000000091
[postgres@lxicbpgdsgv02 ~]$

7.4. Remove and Symlink pg_wal

[postgres@lxicbpgdsgv02 ~]$ rm -rf /pgdata/pgsql17/data/pg_wal
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ln -s /pgwal/pgsql17/wal /pgdata/pgsql17/data/pg_wal
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ls -ld /pgdata/pgsql17/data/pg_wal
lrwxrwxrwx. 1 postgres postgres 18 Oct 12 23:57 /pgdata/pgsql17/data/pg_wal -> /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$

7.5. Update $PGDATA/tablespace_map

[postgres@lxicbpgdsgv02 ~]$ cat /pgdata/pgsql17/data/tablespace_map
16542 /pgTb/pgsql17/tbs/delltbs01
16545 /pgTb/pgsql17/tbs/orcltbs01
[postgres@lxicbpgdsgv02 ~]$

# Update to new location
[postgres@lxicbpgdsgv02 ~]$ sed -i 's|/pgTb/|/pgtsdata01/|g' /pgdata/pgsql17/data/tablespace_map
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ cat /pgdata/pgsql17/data/tablespace_map
16542 /pgtsdata01/pgsql17/tbs/delltbs01
16545 /pgtsdata01/pgsql17/tbs/orcltbs01
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgtsdata01/pgsql17/tbs/delltbs01
total 0
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgtsdata01/pgsql17/tbs/orcltbs01
total 0
[postgres@lxicbpgdsgv02 ~]$

7.6. Restore Tablespace Data

# Restore Tablespace DELL_TB_DATA
[postgres@lxicbpgdsgv02 ~]$ nohup tar -xvf /pgbackup/pgsql17/backup/base_bkp12OCT2025/16542.tar -C /pgtsdata01/pgsql17/tbs/delltbs01 > /pgbackup/pgsql17/backup/16542_restore.log 2>&1 &
[1] 3652
[postgres@lxicbpgdsgv02 ~]$

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgtsdata01/pgsql17/tbs/delltbs01
total 0
drwx------. 3 postgres postgres 19 Oct 11 02:55 PG_17_202406281
[postgres@lxicbpgdsgv02 ~]$

# Restore Tablespace ORCL_TB_DATA
[postgres@lxicbpgdsgv02 ~]$ nohup tar -xvf /pgbackup/pgsql17/backup/base_bkp12OCT2025/16545.tar -C /pgtsdata01/pgsql17/tbs/orcltbs01 > /pgbackup/pgsql17/backup/16545_restore.log 2>&1 &
[1] 3655
[postgres@lxicbpgdsgv02 ~]$

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgtsdata01/pgsql17/tbs/orcltbs01
total 0
drwx------. 3 postgres postgres 19 Oct 11 02:58 PG_17_202406281
[postgres@lxicbpgdsgv02 ~]$

7.7. Restore WAL Archive files to backup location

# Please use this location for restore_command in postgresql.conf file

[postgres@lxicbpgdsgv02 ~]$ cd /pgbackup/pgsql17/backup/
[postgres@lxicbpgdsgv02 backup]$ tar -xvf archive_bkp12OCT2025.tar
archive_bkp12OCT2025/
archive_bkp12OCT2025/00000001000000000000008E
archive_bkp12OCT2025/00000001000000000000008F
archive_bkp12OCT2025/000000010000000000000090
archive_bkp12OCT2025/000000010000000000000091
archive_bkp12OCT2025/000000010000000000000091.00000028.backup
archive_bkp12OCT2025/000000010000000000000092
archive_bkp12OCT2025/000000010000000000000093
[postgres@lxicbpgdsgv02 backup]$

[postgres@lxicbpgdsgv02 backup]$ cd archive_bkp12OCT2025/
[postgres@lxicbpgdsgv02 archive_bkp12OCT2025]$ pwd
/pgbackup/pgsql17/backup/archive_bkp12OCT2025
[postgres@lxicbpgdsgv02 archive_bkp12OCT2025]$ ls -ltr
total 98308
-rw-------. 1 postgres postgres 16777216 Oct 12 22:13 000000010000000000000093
-rw-------. 1 postgres postgres 16777216 Oct 12 22:13 000000010000000000000092
-rw-------. 1 postgres postgres      341 Oct 12 22:13 000000010000000000000091.00000028.backup
-rw-------. 1 postgres postgres 16777216 Oct 12 22:13 000000010000000000000091
-rw-------. 1 postgres postgres 16777216 Oct 12 22:13 000000010000000000000090
-rw-------. 1 postgres postgres 16777216 Oct 12 22:13 00000001000000000000008F
-rw-------. 1 postgres postgres 16777216 Oct 12 22:13 00000001000000000000008E
[postgres@lxicbpgdsgv02 archive_bkp12OCT2025]$

7.8. Create $PGDATA/recovery.signal file


[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/recovery.signal
ls: cannot access '/pgdata/pgsql17/data/recovery.signal': No such file or directory
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ touch /pgdata/pgsql17/data/recovery.signal
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/recovery.signal
-rw-r--r--. 1 postgres postgres 0 Oct 13 00:09 /pgdata/pgsql17/data/recovery.signal  <--------------
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgdata/pgsql17/data/recovery.signal
[postgres@lxicbpgdsgv02 ~]$

7.9. Set Permissions

[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgdata/pgsql17/data
[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgarchive/pgsql17/archive
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgdata/pgsql17/data
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgarchive/pgsql17/archive
[postgres@lxicbpgdsgv02 ~]$

8. PostgreSQL Configuration on Target

8.1. Update postgresql.conf

# • restore_command (Mandatory)
# • recovery_target_time (Mandatory)
# • archive_mode (Optional)
# • archive_command (Optional)
# eg: echo "recovery_target_time = '2025-10-12 22:05:00'" >> /pgdata/pgsql17/data/postgresql.conf

[postgres@lxicbpgdsgv02 ~]$ cat /pgdata/pgsql17/data/postgresql.conf | egrep -i 'archive_|command'
archive_mode = on
archive_command = 'cp %p /pgArch/pgsql17/arch/%f'
[postgres@lxicbpgdsgv02 ~]$

# Update archive_mode=on (Optional)
# Update archive_command='cp %p /pgarchive/pgsql17/archive/%f' (Optional)
# Update restore_command = 'cp /pgbackup/pgsql17/backup/archive_bkp12OCT2025/%f %p' 
# Update recovery_target_time = '2025-10-12 22:05:00'

[postgres@lxicbpgdsgv02 ~]$ cat /pgdata/pgsql17/data/postgresql.conf | egrep -i 'archive_|command|recover'
archive_mode = on
archive_command='cp %p /pgarchive/pgsql17/archive/%f'
restore_command = 'cp /pgbackup/pgsql17/backup/archive_bkp12OCT2025/%f %p'
recovery_target_time = '2025-10-12 22:05:00'
[postgres@lxicbpgdsgv02 ~]$

8.2. Validate PGDATA in systemd and bash shell profile

[postgres@lxicbpgdsgv02 ~]$ cat /usr/lib/systemd/system/postgresql-17.service | grep -i "Environment=PGDATA"
Environment=PGDATA=/pgdata/pgsql17/data
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ cat .bash_profile | grep -i PGDATA=
PGDATA=/pgdata/pgsql17/data
[postgres@lxicbpgdsgv02 ~]$

9. Start PostgreSQL Service

[root@lxicbpgdsgv02 ~]# systemctl start postgresql-17.service
[root@lxicbpgdsgv02 ~]#
[root@lxicbpgdsgv02 ~]# systemctl status postgresql-17.service
● postgresql-17.service - PostgreSQL 17 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-17.service; enabled; preset: disabled)
     Active: active (running) since Mon 2025-10-13 00:28:04 +08; 10min ago
       Docs: https://www.postgresql.org/docs/17/static/
    Process: 3859 ExecStartPre=/usr/pgsql-17/bin/postgresql-17-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 3878 (postgres)
      Tasks: 6 (limit: 20496)
     Memory: 52.4M
        CPU: 221ms
     CGroup: /system.slice/postgresql-17.service
             ├─3878 /usr/pgsql-17/bin/postgres -D /pgdata/pgsql17/data
             ├─3885 "postgres: logger "
             ├─3886 "postgres: checkpointer "
             ├─3887 "postgres: background writer "
             ├─3888 "postgres: startup waiting for 000000010000000000000094"   <---- NO Need to copy this archive log file.
             └─3901 "postgres: postgres dell [local] idle"

Oct 13 00:28:03 lxicbpgdsgv02.rajasekhar.com systemd[1]: Starting PostgreSQL 17 database server...
Oct 13 00:28:03 lxicbpgdsgv02.rajasekhar.com postgres[3878]: 2025-10-13 00:28:03.490 +08 [3878] LOG:  redirecting log output to logging collector process
Oct 13 00:28:03 lxicbpgdsgv02.rajasekhar.com postgres[3878]: 2025-10-13 00:28:03.490 +08 [3878] HINT:  Future log output will appear in directory "log".
Oct 13 00:28:04 lxicbpgdsgv02.rajasekhar.com systemd[1]: Started PostgreSQL 17 database server.
[root@lxicbpgdsgv02 ~]#

10. Final Validation

10.1. Review PostgreSQL Logs

2025-10-13 00:28:03.490 +08 [3878] LOG:  starting PostgreSQL 17.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5), 64-bit
2025-10-13 00:28:03.494 +08 [3878] LOG:  listening on IPv6 address "::1", port 5432
2025-10-13 00:28:03.494 +08 [3878] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2025-10-13 00:28:03.498 +08 [3878] LOG:  listening on Unix socket "/run/postgresql/.s.PGSQL.5432"
2025-10-13 00:28:03.504 +08 [3878] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2025-10-13 00:28:03.510 +08 [3888] LOG:  database system was interrupted; last known up at 2025-10-12 21:57:50 +08
2025-10-13 00:28:03.512 +08 [3888] LOG:  creating missing WAL directory "pg_wal/archive_status"
2025-10-13 00:28:03.512 +08 [3888] LOG:  creating missing WAL directory "pg_wal/summaries"
cp: cannot stat '/pgbackup/pgsql17/backup/archive_bkp12OCT2025/00000002.history': No such file or directory
2025-10-13 00:28:04.414 +08 [3888] LOG:  starting backup recovery with redo LSN 0/91000028, checkpoint LSN 0/91000080, on timeline ID 1
2025-10-13 00:28:04.434 +08 [3888] LOG:  restored log file "000000010000000000000091" from archive
2025-10-13 00:28:04.486 +08 [3888] LOG:  starting point-in-time recovery to 2025-10-12 22:05:00+08
2025-10-13 00:28:04.497 +08 [3888] LOG:  redo starts at 0/91000028
2025-10-13 00:28:04.518 +08 [3888] LOG:  restored log file "000000010000000000000092" from archive
2025-10-13 00:28:04.591 +08 [3888] LOG:  restored log file "000000010000000000000093" from archive
cp: cannot stat '/pgbackup/pgsql17/backup/archive_bkp12OCT2025/000000010000000000000094': No such file or directory
2025-10-13 00:28:04.651 +08 [3888] LOG:  completed backup recovery with redo LSN 0/91000028 and end LSN 0/91000120
2025-10-13 00:28:04.651 +08 [3888] LOG:  consistent recovery state reached at 0/91000120
2025-10-13 00:28:04.652 +08 [3888] LOG:  recovery stopping before commit of transaction 897, time 2025-10-12 22:05:35.873371+08
2025-10-13 00:28:04.652 +08 [3888] LOG:  pausing at the end of recovery
2025-10-13 00:28:04.652 +08 [3888] HINT:  Execute pg_wal_replay_resume() to promote.
2025-10-13 00:28:04.652 +08 [3878] LOG:  database system is ready to accept read-only connections

10.2. Execute pg_wal_replay_resume()

[postgres@lxicbpgdsgv02 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# select pg_wal_replay_resume();
 pg_wal_replay_resume
----------------------

(1 row)

postgres=#

10.3. Review PostgreSQL Logs again

...
2025-10-13 00:30:22.955 +08 [3982] STATEMENT:  pg_wal_replay_resume()
        pg_wal_replay_resume();
2025-10-13 00:32:11.748 +08 [3973] LOG:  redo done at 0/93007B70 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 174.26 s
2025-10-13 00:32:11.768 +08 [3973] LOG:  restored log file "000000010000000000000093" from archive
cp: cannot stat '/pgbackup/pgsql17/backup/archive_bkp12OCT2025/00000002.history': No such file or directory
2025-10-13 00:32:11.827 +08 [3973] LOG:  selected new timeline ID: 2
cp: cannot stat '/pgbackup/pgsql17/backup/archive_bkp12OCT2025/00000001.history': No such file or directory
2025-10-13 00:32:11.957 +08 [3973] LOG:  archive recovery complete
2025-10-13 00:32:11.960 +08 [3971] LOG:  checkpoint starting: end-of-recovery immediate wait
2025-10-13 00:32:11.987 +08 [3971] LOG:  checkpoint complete: wrote 8 buffers (0.0%); 0 WAL file(s) added, 0 removed, 1 recycled; write=0.002 s, sync=0.012 s, total=0.029 s; sync files=7, longest=0.004 s, average=0.002 s; distance=16414 kB, estimate=16414 kB; lsn=0/93007B70, redo lsn=0/93007B70
2025-10-13 00:32:12.006 +08 [3969] LOG:  database system is ready to accept connections
[postgres@lxicbpgdsgv02 ~]$

10.4. Confirm recovery.signal Auto-deletion

# File should be gone after successful recovery.

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/recovery.signal
ls: cannot access '/pgdata/pgsql17/data/recovery.signal': No such file or directory
[postgres@lxicbpgdsgv02 ~]$

10.5. Check DB recovery status

[postgres@lxicbpgdsgv02 ~]$ psql -c "SELECT pg_is_in_recovery();"
 pg_is_in_recovery
-------------------
 f  <--- means recovery is completed.
(1 row)

[postgres@lxicbpgdsgv02 ~]$

10.6. Check Database and Tablespace Listing

[postgres@lxicbpgdsgv02 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# \l+
                                                                                        List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | Locale | ICU Rules |   Access privileges   |  Size   |  Tablespace  |                Description
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------+---------+--------------+--------------------------------------------
 dell      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7755 kB | dell_tb_data |
 orcl      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7569 kB | orcl_tb_data |
 postgres  | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 492 MB  | pg_default   | default administrative connection database
 template0 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7545 kB | pg_default   | unmodifiable empty database
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |              |
 template1 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7569 kB | pg_default   | default template for new databases
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |              |
(5 rows)

postgres=# \db
                     List of tablespaces
     Name     |  Owner   |             Location
--------------+----------+-----------------------------------
 dell_tb_data | postgres | /pgtsdata01/pgsql17/tbs/delltbs01
 orcl_tb_data | postgres | /pgtsdata01/pgsql17/tbs/orcltbs01
 pg_default   | postgres |
 pg_global    | postgres |
(4 rows)

postgres=#

10.7. Verify Application Data

[postgres@lxicbpgdsgv02 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# \c dell
You are now connected to database "dell" as user "postgres".
dell=#
dell=# SELECT * FROM TEST.EMP;
 name | designation | project | company
------+-------------+---------+---------
 Sugi | DBA         | Jetstar | iGATE
 Teja | DBA         | RCM     | iGATE
 RAJ  | DBA         | RCM     | iGATE
 KK   | DBA LEAD    | RCM     | iGATE
 DEV  | DBA MANAGER | RCM     | iGATE
(5 rows)

dell=#

10.8. Validate Symbolic Links for Tablespaces

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/pg_tblspc/
total 0
lrwxrwxrwx. 1 postgres postgres 33 Oct 13 00:28 16545 -> /pgtsdata01/pgsql17/tbs/orcltbs01
lrwxrwxrwx. 1 postgres postgres 33 Oct 13 00:28 16542 -> /pgtsdata01/pgsql17/tbs/delltbs01
[postgres@lxicbpgdsgv02 ~]$

11. Take Backup of dropped table test.emp

[postgres@lxicbpgdsgv02 ~]$ pg_dump -U postgres -d dell -t test.emp -Fc -v -f /pgbackup/pgsql17/backup/table_dell_test-emp.dmp
pg_dump: last built-in OID is 16383
pg_dump: reading extensions
pg_dump: identifying extension members
pg_dump: reading schemas
pg_dump: reading user-defined tables
pg_dump: reading user-defined functions
pg_dump: reading user-defined types
pg_dump: reading procedural languages
pg_dump: reading user-defined aggregate functions
pg_dump: reading user-defined operators
pg_dump: reading user-defined access methods
pg_dump: reading user-defined operator classes
pg_dump: reading user-defined operator families
pg_dump: reading user-defined text search parsers
pg_dump: reading user-defined text search templates
pg_dump: reading user-defined text search dictionaries
pg_dump: reading user-defined text search configurations
pg_dump: reading user-defined foreign-data wrappers
pg_dump: reading user-defined foreign servers
pg_dump: reading default privileges
pg_dump: reading user-defined collations
pg_dump: reading user-defined conversions
pg_dump: reading type casts
pg_dump: reading transforms
pg_dump: reading table inheritance information
pg_dump: reading event triggers
pg_dump: finding extension tables
pg_dump: finding inheritance relationships
pg_dump: reading column info for interesting tables
pg_dump: flagging inherited columns in subtables
pg_dump: reading partitioning data
pg_dump: reading indexes
pg_dump: flagging indexes in partitioned tables
pg_dump: reading extended statistics
pg_dump: reading constraints
pg_dump: reading triggers
pg_dump: reading rewrite rules
pg_dump: reading policies
pg_dump: reading row-level security policies
pg_dump: reading publications
pg_dump: reading publication membership of tables
pg_dump: reading publication membership of schemas
pg_dump: reading subscriptions
pg_dump: reading subscription membership of tables
pg_dump: reading dependency data
pg_dump: saving encoding = UTF8
pg_dump: saving "standard_conforming_strings = on"
pg_dump: saving "search_path = "
pg_dump: saving database definition
pg_dump: dumping contents of table "test.emp"
[postgres@lxicbpgdsgv02 ~]$

12. Transfer backup to source server

[postgres@lxicbpgdsgv02 ~]$ scp /pgbackup/pgsql17/backup/table_dell_test-emp.dmp 192.168.2.51:/pgBackup/pgsql17/backup
postgres@192.168.2.51's password:
table_dell_test-emp.dmp                    100% 1396   836.2KB/s   00:00
[postgres@lxicbpgdsgv02 ~]$

13. Restore dropped table and Validation

[postgres@lxicbpgdsgv01 ~]$ ls -ltr /pgBackup/pgsql17/backup/table_dell_test-emp.dmp
-rw-r--r--. 1 postgres postgres 1396 Oct 13 01:07 /pgBackup/pgsql17/backup/table_dell_test-emp.dmp
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# \c dell
You are now connected to database "dell" as user "postgres".
dell=#
dell=# SELECT * FROM TEST.EMP;
ERROR:  relation "test.emp" does not exist
LINE 1: SELECT * FROM TEST.EMP;
                      ^
dell=#


[postgres@lxicbpgdsgv01 ~]$ pg_restore -l /pgBackup/pgsql17/backup/table_dell_test-emp.dmp
;
; Archive created at 2025-10-13 01:05:27 +08
;     dbname: dell
;     TOC Entries: 6
;     Compression: gzip
;     Dump Version: 1.16-0
;     Format: CUSTOM
;     Integer: 4 bytes
;     Offset: 8 bytes
;     Dumped from database version: 17.6
;     Dumped by pg_dump version: 17.6
;
;
; Selected TOC Entries:
;
218; 1259 16553 TABLE test emp postgres
4334; 0 16553 TABLE DATA test emp postgres
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ pg_restore -U postgres -d dell -v /pgBackup/pgsql17/backup/table_dell_test-emp.dmp
pg_restore: connecting to database for restore
pg_restore: creating TABLE "test.emp"
pg_restore: processing data for table "test.emp"
[postgres@lxicbpgdsgv01 ~]$

dell=# SELECT * FROM TEST.EMP;
 name | designation | project | company
------+-------------+---------+---------
 Sugi | DBA         | Jetstar | iGATE
 Teja | DBA         | RCM     | iGATE
 RAJ  | DBA         | RCM     | iGATE
 KK   | DBA LEAD    | RCM     | iGATE
 DEV  | DBA MANAGER | RCM     | iGATE
(5 rows)

dell=#

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

PostgreSQL Backup & Restore to New Host with WAL Archive files

How to Backup & Restore + Recover a PostgreSQL to New Host using pg_basebackup+WAL Archives

Table of Contents



0. Goal

Perform a full recovery to the latest consistent state by restoring a complete backup taken with pg_basebackup and applying the WAL archive files.

Note: pg_basebackup does not include WAL archive files (archive log files) in its backup; these must be backed up separately.

We have a base backup taken without using –tablespace-mapping, and the restore needs to be performed on a different host with the following differences:

  • Tablespace mount point paths are different from the source server.
  • Archive WAL directory is located in a different path.
  • WAL file (pg_wal) location differs.
  • PGDATA directory path is also different.

1. Environment (Source / Target)

AspectSourceTargetDifference
Hostnamelxicbpgdsgv01lxicbpgdsgv02Different hostnames
IP Address192.168.2.51192.168.2.52Different IPs
OSRHEL 9RHEL 9Same
DB VersionPostgreSQL v17.6PostgreSQL v17.6Same
Archive modearchive_mode=onarchive_mode=onSame
PGDATA/pgData/pgsql17/data/pgdata/pgsql17/dataDifferent path case (D vs d)
WAL Directory/pgWal/pgsql17/wal/pgwal/pgsql17/walDifferent path case (W vs w)
WAL Archive Directory/pgArch/pgsql17/arch/pgarchive/pgsql17/archiveDifferent path case (W vs w)
Backup Directory/pgBackup/pgsql17/backup/pgbackup/pgsql17/backupDifferent path case (B vs b)
restore_commandNot Applicable/pgbackup/pgsql17/backup/archive_bkp11OCT2025restore_command on target server for full recovery using WAL archive files.
Tablespace & PathDELL_TB_DATA:/pgTb/pgsql17/tbs/delltbs01 ORCL_TB_DATA:/pgTb/pgsql17/tbs/orcltbs01DELL_TB_DATA:/pgtsdata01/pgsql17/tbs/delltbs01 ORCL_TB_DATA:/pgtsdata01/pgsql17/tbs/orcltbs01It will restore using the same tablespace names, but at different locations.
DatabasesDELL, ORCLWe will restore both from backupWe will restore both

2. Verify Existing DB Setup

[postgres@lxicbpgdsgv01 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# \l+
                                                                                        List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | Locale | ICU Rules |   Access privileges   |  Size   |  Tablespace  |                Description
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------+---------+--------------+--------------------------------------------
 dell      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7755 kB | dell_tb_data |
 orcl      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7569 kB | orcl_tb_data |
 postgres  | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 492 MB  | pg_default   | default administrative connection database
 template0 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7545 kB | pg_default   | unmodifiable empty database
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |              |
 template1 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7569 kB | pg_default   | default template for new databases
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |              |
(5 rows)

postgres=# \db
                  List of tablespaces
     Name     |  Owner   |          Location
--------------+----------+-----------------------------
 dell_tb_data | postgres | /pgTb/pgsql17/tbs/delltbs01
 orcl_tb_data | postgres | /pgTb/pgsql17/tbs/orcltbs01
 pg_default   | postgres |
 pg_global    | postgres |
(4 rows)

postgres=#

postgres=# \c dell
You are now connected to database "dell" as user "postgres".
dell=# CREATE TABLE test.emp (name TEXT, designation TEXT, project TEXT, company TEXT) TABLESPACE DELL_TB_DATA;
CREATE TABLE
dell=# INSERT INTO test.emp VALUES ('Sugi', 'DBA', 'Jetstar', 'iGATE');
INSERT 0 1
dell=# INSERT INTO test.emp VALUES ('Teja', 'DBA', 'RCM', 'iGATE');
INSERT 0 1
dell=# INSERT INTO test.emp VALUES ('RAJ', 'DBA', 'RCM', 'iGATE');
INSERT 0 1
dell=# CHECKPOINT;
CHECKPOINT
dell=# SELECT * FROM TEST.EMP;
 name | designation | project | company
------+-------------+---------+---------
 Sugi | DBA         | Jetstar | iGATE
 Teja | DBA         | RCM     | iGATE
 RAJ  | DBA         | RCM     | iGATE
(3 rows)

dell=#

3. Pre-requisites

3.1. Verify postgresql.conf

postgres=# SHOW wal_level;
 wal_level
-----------
 replica <----
(1 row)

postgres=# show archive_mode;
 archive_mode
--------------
 on <----
(1 row)

postgres=# show archive_command;
        archive_command
-------------------------------
 cp %p /pgArch/pgsql17/arch/%f
(1 row)

postgres=#

3.2. Verify pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS             METHOD
# Local connections for replication (for pg_basebackup run locally)
local   replication     all                                 trust

# Remote connections for replication (for pg_basebackup run remotely)
#host    replication     repl_user       192.168.2.52/32     scram-sha-256

3.3. Verify User Permissions (REPLICATION or SUPERUSER)

postgres=# \du
                             List of roles
 Role name |                         Attributes
-----------+------------------------------------------------------------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS

postgres=#

3.4. Verify Free Space for Backup

[postgres@lxicbpgdsgv01 ~]$ df -h /pgBackup
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdd1       100G  746M  100G   1% /pgBackup
[postgres@lxicbpgdsgv01 ~]$
# Create directories for base backup and WAL archive log files
[postgres@lxicbpgdsgv01 ~]$ mkdir -p /pgBackup/pgsql17/backup/base_bkp11OCT2025
[postgres@lxicbpgdsgv01 ~]$ mkdir -p /pgBackup/pgsql17/backup/archive_bkp11OCT2025
[postgres@lxicbpgdsgv01 ~]$

4. Take Base Backup and WAL Archive

4.1. Take Base Backup

# Take base backup

[postgres@lxicbpgdsgv01 ~]$ nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/base_bkp11OCT2025 -Ft -Xs -P -v > /pgBackup/pgsql17/backup/base_bkp11OCT2025.log 2>&1 &
[1] 3413
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ cat /pgBackup/pgsql17/backup/base_bkp11OCT2025.log
nohup: ignoring input
pg_basebackup: initiating base backup, waiting for checkpoint to complete
pg_basebackup: checkpoint completed
pg_basebackup: write-ahead log start point: 0/8C000028 on timeline 1
pg_basebackup: starting background WAL receiver
pg_basebackup: created temporary replication slot "pg_basebackup_3416"
  7754/535855 kB (1%), 0/3 tablespaces (...ckup/base_bkp11OCT2025/16542.tar)
  7754/535855 kB (1%), 1/3 tablespaces (...ckup/base_bkp11OCT2025/16542.tar)
 15474/535855 kB (2%), 1/3 tablespaces (...ckup/base_bkp11OCT2025/16545.tar)
 15474/535855 kB (2%), 2/3 tablespaces (...ckup/base_bkp11OCT2025/16545.tar)
157800/535855 kB (29%), 2/3 tablespaces (...ackup/base_bkp11OCT2025/base.tar)
342056/535855 kB (63%), 2/3 tablespaces (...ackup/base_bkp11OCT2025/base.tar)
496488/535855 kB (92%), 2/3 tablespaces (...ackup/base_bkp11OCT2025/base.tar)
535868/535868 kB (100%), 2/3 tablespaces (...ackup/base_bkp11OCT2025/base.tar)
535868/535868 kB (100%), 3/3 tablespaces
pg_basebackup: write-ahead log end point: 0/8C000120
pg_basebackup: waiting for background process to finish streaming ...
pg_basebackup: syncing data to disk ...
pg_basebackup: renaming backup_manifest.tmp to backup_manifest
pg_basebackup: base backup completed <-----
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ du -sh /pgBackup/pgsql17/backup/base_bkp11OCT2025
540M    /pgBackup/pgsql17/backup/base_bkp11OCT2025
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ ls -ltr /pgBackup/pgsql17/backup/base_bkp11OCT2025
total 552504
-rw-------. 1 postgres postgres   7940096 Oct 12 00:42 16542.tar
-rw-------. 1 postgres postgres   7905792 Oct 12 00:42 16545.tar
-rw-------. 1 postgres postgres 532883456 Oct 12 00:42 base.tar
-rw-------. 1 postgres postgres    243611 Oct 12 00:42 backup_manifest
-rw-------. 1 postgres postgres  16778752 Oct 12 00:42 pg_wal.tar
[postgres@lxicbpgdsgv01 ~]$

backup_manifest is a JSON file included inside the tar backup.
It contains metadata about the backup, like:
--> List of all files included in the backup
--> Their sizes and checksums
--> Backup timestamps
--> Backup type (full, incremental, differential)
--> Other metadata needed to verify and restore the backup properly

4.2. Insert new row on table test.emp after backup

postgres=# \c dell
You are now connected to database "dell" as user "postgres".
dell=# INSERT INTO test.emp VALUES ('KK', 'DBA LEAD', 'RCM', 'iGATE');
INSERT 0 1
dell=# CHECKPOINT;
CHECKPOINT
dell=# select * from test.emp;
 name | designation | project | company
------+-------------+---------+---------
 Sugi | DBA         | Jetstar | iGATE
 Teja | DBA         | RCM     | iGATE
 RAJ  | DBA         | RCM     | iGATE
 KK   | DBA LEAD    | RCM     | iGATE <---- New row
(4 rows)

# Switch Archivelog (WAL Archive logs)
dell=# SELECT pg_switch_wal();
 pg_switch_wal
---------------
 0/8D000328
(1 row)

dell=# SELECT pg_switch_wal();
 pg_switch_wal
---------------
 0/8E000000
(1 row)

dell=# SELECT pg_switch_wal();
 pg_switch_wal
---------------
 0/8E000000
(1 row)

dell=#

4.3. Copy WAL Archive Files Separately

[postgres@lxicbpgdsgv01 ~]$ cp /pgArch/pgsql17/arch/* /pgBackup/pgsql17/backup/archive_bkp11OCT2025
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ ls -ltr /pgBackup/pgsql17/backup/archive_bkp11OCT2025
total 65540
-rw-------. 1 postgres postgres 16777216 Oct 12 00:53 00000001000000000000008A
-rw-------. 1 postgres postgres 16777216 Oct 12 00:53 00000001000000000000008B
-rw-------. 1 postgres postgres      341 Oct 12 00:53 00000001000000000000008C.00000028.backup
-rw-------. 1 postgres postgres 16777216 Oct 12 00:53 00000001000000000000008C
-rw-------. 1 postgres postgres 16777216 Oct 12 00:53 00000001000000000000008D
[postgres@lxicbpgdsgv01 ~]$

5. Transfer Base Backup and WAL Archives to Target

[postgres@lxicbpgdsgv01 ~]$ cd /pgBackup/pgsql17/backup/
[postgres@lxicbpgdsgv01 backup]$ ls -ltr
total 4
drwxr-xr-x. 2 postgres postgres   97 Oct 12 00:42 base_bkp11OCT2025
-rw-r--r--. 1 postgres postgres 1286 Oct 12 00:42 base_bkp11OCT2025.log
drwxr-xr-x. 2 postgres postgres  182 Oct 12 00:56 archive_bkp11OCT2025
[postgres@lxicbpgdsgv01 backup]$
[postgres@lxicbpgdsgv01 backup]$ tar -cvf base_bkp11OCT2025.tar base_bkp11OCT2025
base_bkp11OCT2025/
base_bkp11OCT2025/16542.tar
base_bkp11OCT2025/pg_wal.tar
base_bkp11OCT2025/16545.tar
base_bkp11OCT2025/base.tar
base_bkp11OCT2025/backup_manifest
[postgres@lxicbpgdsgv01 backup]$
[postgres@lxicbpgdsgv01 backup]$ tar -cvf archive_bkp11OCT2025.tar archive_bkp11OCT2025
archive_bkp11OCT2025/
archive_bkp11OCT2025/00000001000000000000008A
archive_bkp11OCT2025/00000001000000000000008B
archive_bkp11OCT2025/00000001000000000000008C
archive_bkp11OCT2025/00000001000000000000008C.00000028.backup
archive_bkp11OCT2025/00000001000000000000008D
[postgres@lxicbpgdsgv01 backup]$
[postgres@lxicbpgdsgv01 backup]$ ls -ltr
total 618056
drwxr-xr-x. 2 postgres postgres        97 Oct 12 00:42 base_bkp11OCT2025
-rw-r--r--. 1 postgres postgres      1286 Oct 12 00:42 base_bkp11OCT2025.log
drwxr-xr-x. 2 postgres postgres       182 Oct 12 00:56 archive_bkp11OCT2025
-rw-r--r--. 1 postgres postgres 565760000 Oct 12 01:00 base_bkp11OCT2025.tar
-rw-r--r--. 1 postgres postgres  67123200 Oct 12 01:01 archive_bkp11OCT2025.tar
[postgres@lxicbpgdsgv01 backup]$

[postgres@lxicbpgdsgv01 backup]$ scp *.tar 192.168.2.52:/pgbackup/pgsql17/backup
postgres@192.168.2.52's password:
archive_bkp11OCT2025.tar                      100%   64MB  54.6MB/s   00:01
base_bkp11OCT2025.tar                         100%  540MB  58.3MB/s   00:09
[postgres@lxicbpgdsgv01 backup]$

6. Check and Prepare Target Environment

6.1. Check Existing symbolic link and Mounts

[postgres@lxicbpgdsgv02 ~]$ find /pgdata/pgsql17/data -type l -ls
 67117239      0 lrwxrwxrwx   1 postgres postgres       18 Oct 10 19:43 /pgdata/pgsql17/data/pg_wal -> /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$

6.2. Create Tablespace Directories

[postgres@lxicbpgdsgv02 ~]$ mkdir -p /pgtsdata01/pgsql17/tbs/delltbs01
[postgres@lxicbpgdsgv02 ~]$ mkdir -p /pgtsdata01/pgsql17/tbs/orcltbs01
[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgtsdata01/pgsql17/tbs/delltbs01
[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgtsdata01/pgsql17/tbs/orcltbs01
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgtsdata01/pgsql17/tbs/delltbs01
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgtsdata01/pgsql17/tbs/orcltbs01
[postgres@lxicbpgdsgv02 ~]$

6.3. Stop PostgreSQL

[root@lxicbpgdsgv02 ~]# systemctl stop postgresql-17.service
[root@lxicbpgdsgv02 ~]# ps -ef | grep postgres
root        4269    3222  0 01:14 pts/0    00:00:00 grep --color=auto postgres
[root@lxicbpgdsgv02 ~]#

6.4. Clean Data, WAL, and Archive Directories

# Please ensure a backup is taken, if needed, before deleting the contents.
# Remove $PGDATA contents
[postgres@lxicbpgdsgv02 ~]$ rm -rf /pgdata/pgsql17/data/*
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data
total 0
[postgres@lxicbpgdsgv02 ~]$

# Remove WAL log files (Redo log files)
[postgres@lxicbpgdsgv02 ~]$ rm -rf /pgwal/pgsql17/wal/*
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgwal/pgsql17/wal
total 0
[postgres@lxicbpgdsgv02 ~]$

# Remove WAL Archive log files 
[postgres@lxicbpgdsgv02 ~]$ rm -rf /pgarchive/pgsql17/archive/*
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgarchive/pgsql17/archive
total 0
[postgres@lxicbpgdsgv02 ~]$

7. Restore Backup on Target

7.1. Extract Backup Files

[postgres@lxicbpgdsgv02 ~]$ cd /pgbackup/pgsql17/backup
[postgres@lxicbpgdsgv02 backup]$ ls -ltr
total 618052
-rw-r--r--. 1 postgres postgres  67123200 Oct 12 01:04 archive_bkp11OCT2025.tar
-rw-r--r--. 1 postgres postgres 565760000 Oct 12 01:04 base_bkp11OCT2025.tar
[postgres@lxicbpgdsgv02 backup]$
[postgres@lxicbpgdsgv02 backup]$ tar -xvf base_bkp11OCT2025.tar
base_bkp11OCT2025/
base_bkp11OCT2025/16542.tar
base_bkp11OCT2025/pg_wal.tar
base_bkp11OCT2025/16545.tar
base_bkp11OCT2025/base.tar
base_bkp11OCT2025/backup_manifest
[postgres@lxicbpgdsgv02 backup]$
[postgres@lxicbpgdsgv02 backup]$ tar -xvf archive_bkp11OCT2025.tar
archive_bkp11OCT2025/
archive_bkp11OCT2025/00000001000000000000008A
archive_bkp11OCT2025/00000001000000000000008B
archive_bkp11OCT2025/00000001000000000000008C
archive_bkp11OCT2025/00000001000000000000008C.00000028.backup
archive_bkp11OCT2025/00000001000000000000008D
[postgres@lxicbpgdsgv02 backup]$
[postgres@lxicbpgdsgv02 backup]$ ls -ltr
total 618052
drwxr-xr-x. 2 postgres postgres        97 Oct 12 00:42 base_bkp11OCT2025
drwxr-xr-x. 2 postgres postgres       182 Oct 12 00:56 archive_bkp11OCT2025
-rw-r--r--. 1 postgres postgres  67123200 Oct 12 01:04 archive_bkp11OCT2025.tar
-rw-r--r--. 1 postgres postgres 565760000 Oct 12 01:04 base_bkp11OCT2025.tar
[postgres@lxicbpgdsgv02 backup]$
[postgres@lxicbpgdsgv02 backup]$ cd base_bkp11OCT2025
[postgres@lxicbpgdsgv02 base_bkp11OCT2025]$ ls -ltr
total 552504
-rw-------. 1 postgres postgres   7940096 Oct 12 00:42 16542.tar
-rw-------. 1 postgres postgres   7905792 Oct 12 00:42 16545.tar
-rw-------. 1 postgres postgres  16778752 Oct 12 00:42 pg_wal.tar
-rw-------. 1 postgres postgres 532883456 Oct 12 00:42 base.tar
-rw-------. 1 postgres postgres    243611 Oct 12 00:42 backup_manifest
[postgres@lxicbpgdsgv02 base_bkp11OCT2025]$

7.2. Restore Base Data Directory

# Restore base backup to $PGDATA

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/
total 0
[postgres@lxicbpgdsgv02 ~]$ nohup tar -xvf /pgbackup/pgsql17/backup/base_bkp11OCT2025/base.tar -C /pgdata/pgsql17/data > /pgbackup/pgsql17/backup/base_restore.log 2>&1 &
[1] 4482
[postgres@lxicbpgdsgv02 ~]$

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/
total 80
-rw-------. 1 postgres postgres   227 Oct 10 18:41 backup_label.old
-rw-------. 1 postgres postgres  1169 Oct 10 18:41 postgresql.conf.bkp_10sep2025
-rw-------. 1 postgres postgres 30702 Oct 10 18:41 postgresql.conf.bkp
-rw-------. 1 postgres postgres    88 Oct 10 18:41 postgresql.auto.conf
drwx------. 2 postgres postgres    18 Oct 10 18:41 pg_xact
-rw-------. 1 postgres postgres     3 Oct 10 18:41 PG_VERSION
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_twophase
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_stat_tmp
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_snapshots
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_serial
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_notify
drwx------. 4 postgres postgres    36 Oct 10 18:41 pg_multixact
-rw-------. 1 postgres postgres  2640 Oct 10 18:41 pg_ident.conf
-rw-------. 1 postgres postgres  5600 Oct 10 18:41 pg_hba.conf
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_dynshmem
drwx------. 2 postgres postgres     6 Oct 10 18:41 pg_commit_ts
drwx------. 2 postgres postgres     6 Oct 10 19:45 pg_subtrans
-rw-------. 1 postgres postgres  1169 Oct 11 02:42 postgresql.conf
drwx------. 2 postgres postgres     6 Oct 11 02:57 pg_tblspc
drwx------. 5 postgres postgres    33 Oct 11 03:01 base
drwx------. 2 postgres postgres     6 Oct 12 00:42 pg_replslot
drwx------. 4 postgres postgres    68 Oct 12 00:42 pg_logical
-rw-------. 1 postgres postgres    68 Oct 12 00:42 tablespace_map
-rw-------. 1 postgres postgres   227 Oct 12 00:42 backup_label
drwx------. 4 postgres postgres    45 Oct 12 01:29 pg_wal <-- it created as directory.
drwx------. 2 postgres postgres  4096 Oct 12 01:29 global
drwx------. 2 postgres postgres     6 Oct 12  2025 pg_stat
drwx------. 2 postgres postgres   162 Oct 12  2025 log
-rw-------. 1 postgres postgres    30 Oct 12  2025 current_logfiles
[postgres@lxicbpgdsgv02 ~]$

7.3. Restore WAL Directory

# Restore WAL Files to New WAL location 

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgwal/pgsql17/wal/
total 0
[postgres@lxicbpgdsgv02 ~]$ nohup tar -xvf /pgbackup/pgsql17/backup/base_bkp11OCT2025/pg_wal.tar -C /pgwal/pgsql17/wal > /pgbackup/pgsql17/backup/wal_restore.log 2>&1 &
[1] 4495
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgwal/pgsql17/wal/
total 16384
-rw-------. 1 postgres postgres 16777216 Oct 12 00:42 00000001000000000000008C
[postgres@lxicbpgdsgv02 ~]$

7.4. Remove and Symlink pg_wal

# Remove default pg_wal directory from $PGDATA
# Create symbolic link to new WAL file location 
[postgres@lxicbpgdsgv02 ~]$ rm -rf /pgdata/pgsql17/data/pg_wal
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ln -s /pgwal/pgsql17/wal /pgdata/pgsql17/data/pg_wal
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ls -ld /pgdata/pgsql17/data/pg_wal
lrwxrwxrwx. 1 postgres postgres 18 Oct 12 01:50 /pgdata/pgsql17/data/pg_wal -> /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$

7.5. Update $PGDATA/tablespace_map

[postgres@lxicbpgdsgv02 ~]$ cat /pgdata/pgsql17/data/tablespace_map
16542 /pgTb/pgsql17/tbs/delltbs01
16545 /pgTb/pgsql17/tbs/orcltbs01
[postgres@lxicbpgdsgv02 ~]$

# Update to new location
[postgres@lxicbpgdsgv02 ~]$ sed -i 's|/pgTb/|/pgtsdata01/|g' /pgdata/pgsql17/data/tablespace_map
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ cat /pgdata/pgsql17/data/tablespace_map
16542 /pgtsdata01/pgsql17/tbs/delltbs01
16545 /pgtsdata01/pgsql17/tbs/orcltbs01
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgtsdata01/pgsql17/tbs/delltbs01
total 0
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgtsdata01/pgsql17/tbs/orcltbs01
total 0
[postgres@lxicbpgdsgv02 ~]$

7.6. Restore Tablespace Data

# Restore Tablespace DELL_TB_DATA
[postgres@lxicbpgdsgv02 ~]$ nohup tar -xvf /pgbackup/pgsql17/backup/base_bkp11OCT2025/16542.tar -C /pgtsdata01/pgsql17/tbs/delltbs01 > /pgbackup/pgsql17/backup/16542_restore.log 2>&1 &
[1] 4593
[postgres@lxicbpgdsgv02 ~]$

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgtsdata01/pgsql17/tbs/delltbs01
total 0
drwx------. 3 postgres postgres 19 Oct 11 02:55 PG_17_202406281 <---
[postgres@lxicbpgdsgv02 ~]$

# Restore Tablespace ORCL_TB_DATA
[postgres@lxicbpgdsgv02 ~]$ nohup tar -xvf /pgbackup/pgsql17/backup/base_bkp11OCT2025/16545.tar -C /pgtsdata01/pgsql17/tbs/orcltbs01 > /pgbackup/pgsql17/backup/16545_restore.log 2>&1 &
[1] 4594
[postgres@lxicbpgdsgv02 ~]$

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgtsdata01/pgsql17/tbs/orcltbs01
total 0
drwx------. 3 postgres postgres 19 Oct 11 02:58 PG_17_202406281 <---
[postgres@lxicbpgdsgv02 ~]$

7.7. Restore WAL Archive files to backup location

# I have already extracted Archivelog files in the step number 7.1
# Please use this location for restore_command in postgresql.conf file

[postgres@lxicbpgdsgv02 ~]$ cd /pgbackup/pgsql17/backup/archive_bkp11OCT2025/
[postgres@lxicbpgdsgv02 archive_bkp11OCT2025]$ ls -ltr
total 65540
-rw-------. 1 postgres postgres 16777216 Oct 12 00:53 00000001000000000000008D
-rw-------. 1 postgres postgres      341 Oct 12 00:53 00000001000000000000008C.00000028.backup
-rw-------. 1 postgres postgres 16777216 Oct 12 00:53 00000001000000000000008C
-rw-------. 1 postgres postgres 16777216 Oct 12 00:53 00000001000000000000008B
-rw-------. 1 postgres postgres 16777216 Oct 12 00:53 00000001000000000000008A
[postgres@lxicbpgdsgv02 archive_bkp11OCT2025]$

7.8. Create $PGDATA/recovery.signal file

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/recovery.signal
ls: cannot access '/pgdata/pgsql17/data/recovery.signal': No such file or directory
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ touch /pgdata/pgsql17/data/recovery.signal
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/recovery.signal
-rw-r--r--. 1 postgres postgres 0 Oct 12 02:06 /pgdata/pgsql17/data/recovery.signal
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgdata/pgsql17/data/recovery.signal
[postgres@lxicbpgdsgv02 ~]$

7.9. Set Permissions

[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgdata/pgsql17/data
[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgarchive/pgsql17/archive
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgdata/pgsql17/data
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgarchive/pgsql17/archive
[postgres@lxicbpgdsgv02 ~]$

8. PostgreSQL Configuration on Target

8.1. Update postgresql.conf

# • restore_command
# • archive_mode (Optional)
# • archive_command (Optional)

[postgres@lxicbpgdsgv02 ~]$ cat /pgdata/pgsql17/data/postgresql.conf | egrep -i 'archive_|command'
archive_mode = on
archive_command = 'cp %p /pgArch/pgsql17/arch/%f'
[postgres@lxicbpgdsgv02 ~]$

# Update archive_mode=on (Optional)
# Update archive_command='cp %p /pgarchive/pgsql17/archive/%f' (Optional)
# Update restore_command = 'cp /pgbackup/pgsql17/backup/archive_bkp11OCT2025/%f %p'  <--- Must required for full recovery using WAL Archive log files.

[postgres@lxicbpgdsgv02 ~]$ cat /pgdata/pgsql17/data/postgresql.conf | egrep -i 'archive_|command'
archive_mode = on
archive_command='cp %p /pgarchive/pgsql17/archive/%f'
restore_command = 'cp /pgbackup/pgsql17/backup/archive_bkp11OCT2025/%f %p' <---- must be set correctly
[postgres@lxicbpgdsgv02 ~]$

8.2. Validate PGDATA in systemd and bash shell profile

[postgres@lxicbpgdsgv02 ~]$ cat /usr/lib/systemd/system/postgresql-17.service | grep -i "Environment=PGDATA"
Environment=PGDATA=/pgdata/pgsql17/data
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ cat .bash_profile | grep -i PGDATA=
PGDATA=/pgdata/pgsql17/data
[postgres@lxicbpgdsgv02 ~]$

9. Start PostgreSQL Service

[root@lxicbpgdsgv02 ~]# systemctl start postgresql-17.service
[root@lxicbpgdsgv02 ~]#
[root@lxicbpgdsgv02 ~]# systemctl status postgresql-17.service
● postgresql-17.service - PostgreSQL 17 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-17.service; enabled; preset: disabled)
     Active: active (running) since Sun 2025-10-12 02:23:36 +08; 1min 17s ago
       Docs: https://www.postgresql.org/docs/17/static/
    Process: 4887 ExecStartPre=/usr/pgsql-17/bin/postgresql-17-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 4892 (postgres)
      Tasks: 8 (limit: 20496)
     Memory: 66.3M
        CPU: 200ms
     CGroup: /system.slice/postgresql-17.service
             ├─4892 /usr/pgsql-17/bin/postgres -D /pgdata/pgsql17/data
             ├─4893 "postgres: logger "
             ├─4894 "postgres: checkpointer "
             ├─4895 "postgres: background writer "
             ├─4905 "postgres: walwriter "
             ├─4906 "postgres: autovacuum launcher "
             ├─4907 "postgres: archiver last was 00000002.history"
             └─4908 "postgres: logical replication launcher "

Oct 12 02:23:35 lxicbpgdsgv02.rajasekhar.com systemd[1]: Starting PostgreSQL 17 database server...
Oct 12 02:23:35 lxicbpgdsgv02.rajasekhar.com postgres[4892]: 2025-10-12 02:23:35.389 +08 [4892] LOG:  redirecting log output to logging collector process
Oct 12 02:23:35 lxicbpgdsgv02.rajasekhar.com postgres[4892]: 2025-10-12 02:23:35.389 +08 [4892] HINT:  Future log output will appear in directory "log".
Oct 12 02:23:36 lxicbpgdsgv02.rajasekhar.com systemd[1]: Started PostgreSQL 17 database server.
[root@lxicbpgdsgv02 ~]#

10. Final Validation

10.1. Check Database and Tablespace Listing

[postgres@lxicbpgdsgv02 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# \l+
                                                                                        List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | Locale | ICU Rules |   Access privileges   |  Size   |  Tablespace  |                Description
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------+---------+--------------+--------------------------------------------
 dell      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7755 kB | dell_tb_data |
 orcl      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7569 kB | orcl_tb_data |
 postgres  | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 492 MB  | pg_default   | default administrative connection database
 template0 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7545 kB | pg_default   | unmodifiable empty database
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |              |
 template1 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7569 kB | pg_default   | default template for new databases
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |              |
(5 rows)

postgres=# \db
                     List of tablespaces
     Name     |  Owner   |             Location
--------------+----------+-----------------------------------
 dell_tb_data | postgres | /pgtsdata01/pgsql17/tbs/delltbs01
 orcl_tb_data | postgres | /pgtsdata01/pgsql17/tbs/orcltbs01
 pg_default   | postgres |
 pg_global    | postgres |
(4 rows)

postgres=#

10.2. Verify Application Data

[postgres@lxicbpgdsgv02 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# \c dell
You are now connected to database "dell" as user "postgres".
dell=# select * from test.emp;
 name | designation | project | company
------+-------------+---------+---------
 Sugi | DBA         | Jetstar | iGATE
 Teja | DBA         | RCM     | iGATE
 RAJ  | DBA         | RCM     | iGATE
 KK   | DBA LEAD    | RCM     | iGATE <----
(4 rows)

dell=# exit
[postgres@lxicbpgdsgv02 ~]$

10.3. Validate Symbolic Links for Tablespaces

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/pg_tblspc/
total 0
lrwxrwxrwx. 1 postgres postgres 33 Oct 12 02:23 16545 -> /pgtsdata01/pgsql17/tbs/orcltbs01
lrwxrwxrwx. 1 postgres postgres 33 Oct 12 02:23 16542 -> /pgtsdata01/pgsql17/tbs/delltbs01
[postgres@lxicbpgdsgv02 ~]$

10.4. Confirm recovery.signal Auto-deletion

# File should be gone after successful recovery.

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/recovery.signal
ls: cannot access '/pgdata/pgsql17/data/recovery.signal': No such file or directory
[postgres@lxicbpgdsgv02 ~]$

10.5. Review PostgreSQL Logs

[postgres@lxicbpgdsgv02 ~]$ cat /pgdata/pgsql17/data/log/postgresql-Sun.log
...
...
2025-10-12 02:23:35.389 +08 [4892] LOG:  starting PostgreSQL 17.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5), 64-bit
2025-10-12 02:23:35.391 +08 [4892] LOG:  listening on IPv6 address "::1", port 5432
2025-10-12 02:23:35.392 +08 [4892] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2025-10-12 02:23:35.409 +08 [4892] LOG:  listening on Unix socket "/run/postgresql/.s.PGSQL.5432"
2025-10-12 02:23:35.418 +08 [4892] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2025-10-12 02:23:35.424 +08 [4896] LOG:  database system was interrupted; last known up at 2025-10-12 00:42:13 +08
2025-10-12 02:23:35.424 +08 [4896] LOG:  creating missing WAL directory "pg_wal/archive_status"
2025-10-12 02:23:35.424 +08 [4896] LOG:  creating missing WAL directory "pg_wal/summaries"
cp: cannot stat '/pgbackup/pgsql17/backup/archive_bkp11OCT2025/00000002.history': No such file or directory
2025-10-12 02:23:36.418 +08 [4896] LOG:  starting backup recovery with redo LSN 0/8C000028, checkpoint LSN 0/8C000080, on timeline ID 1
2025-10-12 02:23:36.440 +08 [4896] LOG:  restored log file "00000001000000000000008C" from archive
2025-10-12 02:23:36.505 +08 [4896] LOG:  starting archive recovery
2025-10-12 02:23:36.516 +08 [4896] LOG:  redo starts at 0/8C000028
2025-10-12 02:23:36.539 +08 [4896] LOG:  restored log file "00000001000000000000008D" from archive
cp: cannot stat '/pgbackup/pgsql17/backup/archive_bkp11OCT2025/00000001000000000000008E': No such file or directory
2025-10-12 02:23:36.597 +08 [4896] LOG:  completed backup recovery with redo LSN 0/8C000028 and end LSN 0/8C000120
2025-10-12 02:23:36.597 +08 [4896] LOG:  consistent recovery state reached at 0/8C000120
2025-10-12 02:23:36.599 +08 [4892] LOG:  database system is ready to accept read-only connections
cp: cannot stat '/pgbackup/pgsql17/backup/archive_bkp11OCT2025/00000001000000000000008E': No such file or directory
2025-10-12 02:23:36.612 +08 [4896] LOG:  redo done at 0/8D000310 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.09 s
2025-10-12 02:23:36.612 +08 [4896] LOG:  last completed transaction was at log time 2025-10-12 00:52:29.813112+08
2025-10-12 02:23:36.639 +08 [4896] LOG:  restored log file "00000001000000000000008D" from archive
cp: cannot stat '/pgbackup/pgsql17/backup/archive_bkp11OCT2025/00000002.history': No such file or directory
2025-10-12 02:23:36.700 +08 [4896] LOG:  selected new timeline ID: 2
cp: cannot stat '/pgbackup/pgsql17/backup/archive_bkp11OCT2025/00000001.history': No such file or directory
2025-10-12 02:23:36.779 +08 [4896] LOG:  archive recovery complete
2025-10-12 02:23:36.782 +08 [4894] LOG:  checkpoint starting: end-of-recovery immediate wait
2025-10-12 02:23:36.810 +08 [4894] LOG:  checkpoint complete: wrote 4 buffers (0.0%); 0 WAL file(s) added, 0 removed, 2 recycled; write=0.002 s, sync=0.008 s, total=0.031 s; sync files=3, longest=0.003 s, average=0.003 s; distance=32768 kB, estimate=32768 kB; lsn=0/8E000028, redo lsn=0/8E000028
2025-10-12 02:23:36.823 +08 [4892] LOG:  database system is ready to accept connections
[postgres@lxicbpgdsgv02 ~]$

10.6. Check DB recovery status

[postgres@lxicbpgdsgv02 ~]$ psql -c "SELECT pg_is_in_recovery();"
 pg_is_in_recovery
-------------------
 f  <--- means recovery is completed.
(1 row)

[postgres@lxicbpgdsgv02 ~]$

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

Backup and Restore on Same Host Using pg_basebackup

How to Backup and Restore PostgreSQL DB Cluster on the Same Host Using pg_basebackup

Table of Contents


1. Environment
2. Verify Existing DB Setup
3. Pre-requisites
4. Take Backup
5. Prepare & Restore
     5.1 Stop PostgreSQL and Clean Directories
     5.2 Remove all from Data & WAL directories
     5.3 Restore Data and WAL
         A. Copy Backup files to $PGDATA
         B. Copy WAL files from $PGDATA/pg_wal to /pgWal/pgsql17/wal/
         C. Remove the existing $PGDATA/pg_wal directory
         D. Create a symbolic link pointing $PGDATA/pg_wal to a separate WAL directory
         E. Set Permissions
6. Start PostgreSQL
7. Final Verification


1. Environment

ASPECTEnv
Hostnamelxicbpgdsgv01
IP Address192.168.2.51
OSRHEL 9
DB VersionPostgreSQL v17.6
Archive modearchive_mode=off
pgData/pgData/pgsql17/data
WAL Directory/pgWal/pgsql17/wal
Tablespacepg_default
DatabasesDELL, ORCL

2. Verify Existing DB Setup

[postgres@lxicbpgdsgv01 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# \l+
                                                                                       List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | Locale | ICU Rules |   Access privileges   |  Size   | Tablespace |                Description
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------+---------+------------+--------------------------------------------
 dell      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7763 kB | pg_default |
 orcl      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7907 kB | pg_default |
 postgres  | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 492 MB  | pg_default | default administrative connection database
 template0 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7545 kB | pg_default | unmodifiable empty database
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |            |
 template1 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7723 kB | pg_default | default template for new databases
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |            |
(5 rows)

postgres=# \db
       List of tablespaces
    Name    |  Owner   | Location
------------+----------+----------
 pg_default | postgres |
 pg_global  | postgres |
(2 rows)

postgres=# \c dell
You are now connected to database "dell" as user "postgres".
dell=# select * from test.emp;
 name | designation | project | company
------+-------------+---------+---------
 Sugi | DBA         | Jetstar | iGATE
 Teja | DBA         | RCM     | iGATE
 RAJ  | DBA         | RCM     | iGATE
(3 rows)

dell=#

3. Pre-requisites

  • Verify postgresql.conf
postgres=# SHOW wal_level;
 wal_level
-----------
 replica <----
(1 row)

postgres=#
postgres=# SHOW max_wal_senders;
 max_wal_senders
-----------------
 10
(1 row)

postgres=# SHOW archive_mode;
 archive_mode
--------------
 off
(1 row)

postgres=# 
  • Verify pg_hba.conf
# TYPE  DATABASE        USER            ADDRESS             METHOD
# Local connections for replication (for pg_basebackup run locally)
local   replication     all                                 trust

# Remote connections for replication (for pg_basebackup run remotely)
#host    replication     repl_user       192.168.2.52/32     scram-sha-256

  • Verify user permissions:REPLICATION or SUPERUSER required
postgres=# \du
                             List of roles
 Role name |                         Attributes
-----------+------------------------------------------------------------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS

postgres=#
  • Verify free space for backup
[postgres@lxicbpgdsgv01 ~]$ du -sh /pgData/pgsql17/data/
524M    /pgData/pgsql17/data/
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ du -sh /pgWal/pgsql17/wal/
801M    /pgWal/pgsql17/wal/
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ df -h /pgBackup/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdd1       100G  746M  100G   1% /pgBackup <----
[postgres@lxicbpgdsgv01 ~]$ mkdir -p /pgBackup/pgsql17/backup/basebackup_10OCT2025
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ mkdir -p /pgBackup/pgsql17/backup/log/
[postgres@lxicbpgdsgv01 ~]$

4. Take Backup

[postgres@lxicbpgdsgv01 ~]$ ls -ltrh /pgWal/pgsql17/wal | wc -l
53 <---- 
[postgres@lxicbpgdsgv01 ~]$

pg_basebackup does not include all files from the pg_wal directory in the backup. Instead, it selectively includes only the WAL files required to make the base backup consistent at the point in time the backup was taken.

-- If you want to store the base backup and WAL files in separate backup directories. 

nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/basebackup_10OCT2025 --waldir=/pgBackup/pgsql17/backup/wal_backup -Fp -Xs -P -v > /pgBackup/pgsql17/backup/log/basebackup_10OCT2025.log 2>&1 &

The --waldir option in pg_basebackup is supported only when using the plain format (-Fp), not with the tar format (-Ft).

If we want symlinks preserved → use (both -Fp & --waldir use together) -Fp --waldir=/pgWal/pgsql17/wal

-- OR --

The directory mush be empty: /pgBackup/pgsql17/backup/basebackup_10OCT2025

[postgres@lxicbpgdsgv01 ~]$ nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/basebackup_10OCT2025 -Fp -Xs -P -v > /pgBackup/pgsql17/backup/log/basebackup_10OCT2025.log 2>&1 &
[1] 4973
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ cat /pgBackup/pgsql17/backup/log/basebackup_10OCT2025.log
nohup: ignoring input
pg_basebackup: initiating base backup, waiting for checkpoint to complete
pg_basebackup: checkpoint completed
pg_basebackup: write-ahead log start point: 0/85000028 on timeline 1
pg_basebackup: starting background WAL receiver
pg_basebackup: created temporary replication slot "pg_basebackup_4975"
279413/536037 kB (52%), 0/1 tablespace (...asebackup_10OCT2025/base/5/16533)
536047/536047 kB (100%), 0/1 tablespace (...ckup_10OCT2025/global/pg_control)
536047/536047 kB (100%), 1/1 tablespace
pg_basebackup: write-ahead log end point: 0/85000158
pg_basebackup: waiting for background process to finish streaming ...
pg_basebackup: syncing data to disk ...
pg_basebackup: renaming backup_manifest.tmp to backup_manifest
pg_basebackup: base backup completed  <-----
[postgres@lxicbpgdsgv01 ~]$

5. Prepare & Restore

5.1 Stop PostgreSQL and Clean Directories

[root@lxicbpgdsgv01 ~]# systemctl stop postgresql-17.service
[root@lxicbpgdsgv01 ~]# 
[root@lxicbpgdsgv01 ~]# ps -ef | grep postgres
root        5057    3151  0 18:57 pts/0    00:00:00 grep --color=auto postgres
[root@lxicbpgdsgv01 ~]#

5.2 Remove all from Data & WAL directories

-- Remove all from PGDATA directory

[root@lxicbpgdsgv01 ~]# rm -rf /pgData/pgsql17/data/*
[root@lxicbpgdsgv01 ~]# ls -ltr /pgData/pgsql17/data/
total 0
[root@lxicbpgdsgv01 ~]#

-- Remove all from WAL directory 

[root@lxicbpgdsgv01 ~]# rm -rf /pgWal/pgsql17/wal/*
[root@lxicbpgdsgv01 ~]# ls -ltr /pgWal/pgsql17/wal/
total 0
[root@lxicbpgdsgv01 ~]#

5.3 Restore Data and WAL

A. Copy Backup files to $PGDATA
Since we did not use the -Fp format with the --waldir option, all required WAL files will be included in the backup under the default path: PGDATA/pg_wal.

[postgres@lxicbpgdsgv01 ~]$ ls -ltr /pgData/pgsql17/data/
total 0
[postgres@lxicbpgdsgv01 ~]$ cd /pgBackup/pgsql17/backup/basebackup_10OCT2025/
[postgres@lxicbpgdsgv01 basebackup_10OCT2025]$ cp -Rp * /pgData/pgsql17/data/
[postgres@lxicbpgdsgv01 basebackup_10OCT2025]$
[postgres@lxicbpgdsgv01 basebackup_10OCT2025]$ ls -ltr /pgData/pgsql17/data/
total 296
-rw-------. 1 postgres postgres    227 Oct 10 18:41 backup_label
drwx------. 4 postgres postgres     77 Oct 10 18:41 pg_wal
drwx------. 7 postgres postgres     59 Oct 10 18:41 base
drwx------. 4 postgres postgres     68 Oct 10 18:41 pg_logical
drwx------. 2 postgres postgres      6 Oct 10 18:41 pg_dynshmem
drwx------. 2 postgres postgres      6 Oct 10 18:41 pg_commit_ts
drwx------. 2 postgres postgres    110 Oct 10 18:41 log
-rw-------. 1 postgres postgres   1169 Oct 10 18:41 postgresql.conf.bkp_10sep2025
-rw-------. 1 postgres postgres  30702 Oct 10 18:41 postgresql.conf.bkp
-rw-------. 1 postgres postgres     88 Oct 10 18:41 postgresql.auto.conf
drwx------. 2 postgres postgres     18 Oct 10 18:41 pg_xact
-rw-------. 1 postgres postgres      3 Oct 10 18:41 PG_VERSION
drwx------. 2 postgres postgres      6 Oct 10 18:41 pg_twophase
drwx------. 2 postgres postgres      6 Oct 10 18:41 pg_tblspc
drwx------. 2 postgres postgres      6 Oct 10 18:41 pg_subtrans
drwx------. 2 postgres postgres      6 Oct 10 18:41 pg_stat_tmp
drwx------. 2 postgres postgres      6 Oct 10 18:41 pg_stat
drwx------. 2 postgres postgres      6 Oct 10 18:41 pg_snapshots
drwx------. 2 postgres postgres      6 Oct 10 18:41 pg_serial
drwx------. 2 postgres postgres      6 Oct 10 18:41 pg_replslot
drwx------. 2 postgres postgres      6 Oct 10 18:41 pg_notify
drwx------. 4 postgres postgres     36 Oct 10 18:41 pg_multixact
-rw-------. 1 postgres postgres   2640 Oct 10 18:41 pg_ident.conf
-rw-------. 1 postgres postgres   5600 Oct 10 18:41 pg_hba.conf
-rw-------. 1 postgres postgres   1171 Oct 10 18:41 postgresql.conf
drwx------. 2 postgres postgres   4096 Oct 10 18:41 global
-rw-------. 1 postgres postgres     30 Oct 10 18:41 current_logfiles
-rw-------. 1 postgres postgres 227736 Oct 10 18:41 backup_manifest
[postgres@lxicbpgdsgv01 basebackup_10OCT2025]$
B. Copy WAL files from $PGDATA/pg_wal to /pgWal/pgsql17/wal/
[postgres@lxicbpgdsgv01 ~]$ ls -ltr /pgWal/pgsql17/wal/
total 0
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ cd /pgData/pgsql17/data/pg_wal/
[postgres@lxicbpgdsgv01 pg_wal]$ cp -Rp * /pgWal/pgsql17/wal
[postgres@lxicbpgdsgv01 pg_wal]$
[postgres@lxicbpgdsgv01 pg_wal]$ ls -ltr /pgWal/pgsql17/wal
total 16384
drwx------. 2 postgres postgres        6 Oct 10 18:41 summaries
drwx------. 2 postgres postgres        6 Oct 10 18:41 archive_status
-rw-------. 1 postgres postgres 16777216 Oct 10 18:41 000000010000000000000085
[postgres@lxicbpgdsgv01 pg_wal]$ cd
[postgres@lxicbpgdsgv01 ~]$
C. Remove the existing $PGDATA/pg_wal directory
[postgres@lxicbpgdsgv01 ~]$ rm -rf /pgData/pgsql17/data/pg_wal
[postgres@lxicbpgdsgv01 ~]$
D. Create a symbolic link pointing $PGDATA/pg_wal to a separate WAL directory
[postgres@lxicbpgdsgv01 ~]$ ln -s /pgWal/pgsql17/wal /pgData/pgsql17/data/pg_wal
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ ls -ld /pgData/pgsql17/data/pg_wal
lrwxrwxrwx. 1 postgres postgres 18 Oct 10 19:43 /pgData/pgsql17/data/pg_wal -> /pgWal/pgsql17/wal
[postgres@lxicbpgdsgv01 ~]$
E. Set Permissions
[postgres@lxicbpgdsgv01 ~]$ chown -R postgres:postgres /pgData/pgsql17/data
[postgres@lxicbpgdsgv01 ~]$ chmod 700 /pgData/pgsql17/data
[postgres@lxicbpgdsgv01 ~]$ chown -R postgres:postgres /pgWal/pgsql17/wal
[postgres@lxicbpgdsgv01 ~]$ chmod 700 /pgWal/pgsql17/wal

6. Start PostgreSQL

[root@lxicbpgdsgv01 ~]# systemctl start postgresql-17.service
[root@lxicbpgdsgv01 ~]# systemctl status postgresql-17.service
● postgresql-17.service - PostgreSQL 17 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-17.service; enabled; preset: disabled)
     Active: active (running) since Fri 2025-10-10 19:45:21 +08; 5s ago
       Docs: https://www.postgresql.org/docs/17/static/
    Process: 5230 ExecStartPre=/usr/pgsql-17/bin/postgresql-17-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 5235 (postgres)
      Tasks: 7 (limit: 15835)
     Memory: 34.2M
        CPU: 94ms
     CGroup: /system.slice/postgresql-17.service
             ├─5235 /usr/pgsql-17/bin/postgres -D /pgData/pgsql17/data/
             ├─5236 "postgres: logger "
             ├─5237 "postgres: checkpointer "
             ├─5238 "postgres: background writer "
             ├─5240 "postgres: walwriter "
             ├─5241 "postgres: autovacuum launcher "
             └─5242 "postgres: logical replication launcher "

Oct 10 19:45:21 lxicbpgdsgv01.rajasekhar.com systemd[1]: Starting PostgreSQL 17 database server...
Oct 10 19:45:21 lxicbpgdsgv01.rajasekhar.com postgres[5235]: 2025-10-10 19:45:21.177 +08 [5235] LOG:  redirecting log output to logging collector process
Oct 10 19:45:21 lxicbpgdsgv01.rajasekhar.com postgres[5235]: 2025-10-10 19:45:21.177 +08 [5235] HINT:  Future log output will appear in directory "log".
Oct 10 19:45:21 lxicbpgdsgv01.rajasekhar.com systemd[1]: Started PostgreSQL 17 database server.
[root@lxicbpgdsgv01 ~]#

7. Final Verification

[postgres@lxicbpgdsgv01 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# \l+
                                                                                       List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | Locale | ICU Rules |   Access privileges   |  Size   | Tablespace |                Description
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------+---------+------------+--------------------------------------------
 dell      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7609 kB | pg_default |
 orcl      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7753 kB | pg_default |
 postgres  | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 492 MB  | pg_default | default administrative connection database
 template0 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7545 kB | pg_default | unmodifiable empty database
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |            |
 template1 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7569 kB | pg_default | default template for new databases
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |            |
(5 rows)

postgres=# \db
       List of tablespaces
    Name    |  Owner   | Location
------------+----------+----------
 pg_default | postgres |
 pg_global  | postgres |
(2 rows)

postgres=# \c dell
You are now connected to database "dell" as user "postgres".
dell=# select * from test.emp;
 name | designation | project | company
------+-------------+---------+---------
 Sugi | DBA         | Jetstar | iGATE
 Teja | DBA         | RCM     | iGATE
 RAJ  | DBA         | RCM     | iGATE
(3 rows)

dell=#

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

Clone PostgreSQL Cluster from One Host to Another Using pg_basebackup (No Archive Mode)

How To Backup and Restore PostgreSQL DB Cluster from One Host to Another Using pg_basebackup (No Archive Mode)

Table of Contents


1. Goal
2. Environment (Source / Target)
3. Verify Existing Setup
4. Verify postgresql.conf
5. Verify pg_hba.conf
6. Verify Users
7. Directory Permissions
8. Take Backup
9. Verify Backup
10. Transfer Backup to Target
11. Prepare Target & Restore

                  11.1 Backup Target (Optional)
                  11.2 Stop PostgreSQL and Clean Directories
                  11.3 Restore Data and WAL
                  11.4 Set Permissions
                  11.5 Verify Restored Files
                  11.6 Create Symbolic Link for WAL

12. Start PostgreSQL on Target
13. Final Verification


In PostgreSQL, a cluster is a group of databases managed by one PostgreSQL server. This is just a standalone server, not like an Oracle RAC cluster.

1. Goal

1. Perform a consistent backup using pg_basebackup from lxicbpgdsgv01.
2. Restore the backup on lxicbpgdsgv02 without applying archived WALs.

2. Environment (Source / Target)

AspectSourceTargetDifference
Hostnamelxicbpgdsgv01lxicbpgdsgv02Different hostnames
IP Address192.168.2.51192.168.2.52Different IPs
OSRHEL 9RHEL 9Same
DB VersionPostgreSQL v17.6PostgreSQL v17.6Same
Archive modeNo ArchivelogNo ArchivelogSame
PGDATA/pgData/pgsql17/data/pgdata/pgsql17/dataDifferent path case (D vs d)
WAL Directory/pgWal/pgsql17/wal/pgwal/pgsql17/walDifferent path case (W vs w)
Tablespacepg_defaultpg_defaultSame
DatabasesDELL, ORCLNo DatabasesNeed to clone

 3. Verify Existing Setup

[postgres@lxicbpgdsgv01 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# \l+
                                                                                       List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | Locale | ICU Rules |   Access privileges   |  Size   | Tablespace |                Description
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------+---------+------------+--------------------------------------------
 dell      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7763 kB | pg_default |
 orcl      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7907 kB | pg_default |
 postgres  | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 492 MB  | pg_default | default administrative connection database
 template0 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7545 kB | pg_default | unmodifiable empty database
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |            |
 template1 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7723 kB | pg_default | default template for new databases
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |            |
(5 rows)

postgres=#

postgres=# \c dell
You are now connected to database "dell" as user "postgres".
dell=#

dell=# \db
       List of tablespaces
    Name    |  Owner   | Location
------------+----------+----------
 pg_default | postgres |
 pg_global  | postgres |
(2 rows)

dell=# 
dell=# \dn test
 List of schemas
 Name |  Owner
------+----------
 test | postgres
(1 row)

dell=#
dell=# \echo :AUTOCOMMIT
on
dell=#

dell=# CREATE TABLE test.emp ( name TEXT, designation TEXT, project TEXT, company TEXT);
CREATE TABLE
dell=# INSERT INTO test.emp VALUES ('Sugi', 'DBA', 'Jetstar', 'iGATE');
INSERT 0 1
dell=# INSERT INTO test.emp VALUES ('Teja', 'DBA', 'RCM', 'iGATE');
INSERT 0 1
dell=# INSERT INTO test.emp VALUES ('RAJ', 'DBA', 'RCM', 'iGATE');
INSERT 0 1
dell=#
dell=# select * from test.emp;
 name | designation | project | company
------+-------------+---------+---------
 Sugi | DBA         | Jetstar | iGATE
 Teja | DBA         | RCM     | iGATE
 RAJ  | DBA         | RCM     | iGATE
(3 rows)

dell=#

dell=# \c orcl
You are now connected to database "orcl" as user "postgres".
orcl=#
orcl=# \dt
            List of relations
 Schema |    Name     | Type  |  Owner
--------+-------------+-------+----------
 public | sample_data | table | postgres
(1 row)

orcl=#
orcl=# select count(*) from sample_data;
 count
-------
  1000  <----- 
(1 row)

orcl=#

4. Verify postgresql.conf


postgres=# SHOW wal_level;
 wal_level
-----------
 replica  <---- Should be replica
(1 row)

postgres=#
postgres=# SHOW max_wal_senders;
 max_wal_senders
-----------------
 10 <----- 
(1 row)

postgres=# SHOW archive_mode;
 archive_mode
--------------
 off  <----- No archive log mode
(1 row)

postgres=# show archive_command;
 archive_command
-----------------
 (disabled)
(1 row)

postgres=#

5. Verify pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS             METHOD
# Local connections for replication (for pg_basebackup run locally)
local   replication     all                                 trust

# Remote connections for replication (for pg_basebackup run remotely)
#host    replication     repl_user       192.168.2.52/32     scram-sha-256

6. Verify user permissions:REPLICATION or SUPERUSER required

postgres=# \du
                             List of roles
 Role name |                         Attributes
-----------+------------------------------------------------------------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS

postgres=#

7. Directory Permissions for Backup

[postgres@lxicbpgdsgv01 ~]$ ls -ld /pgBackup/pgsql17/backup/
drwx------. 2 postgres postgres 6 Oct  9 18:46 /pgBackup/pgsql17/backup/
[postgres@lxicbpgdsgv01 ~]$

8. Take Backup

  • Want symlinks preserved → use (both -Fp & –waldir)-Fp --waldir=/pgWal/pgsql17/wal
  • Want single tar archive → use -Ft, but recreate symlinks after restore, for pg_wal
  • The –waldir option in pg_basebackup is supported only when using the plain format (-Fp), not with the tar format (-Ft).
[postgres@lxicbpgdsgv01 ~]$ nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/pg_basebackup_lxicbpgdsgv01_10sep2025 -Ft -Xs -P > /pgBackup/pgsql17/backup/pg_basebackup_lxicbpgdsgv01_10sep2025.log 2>&1 &
[1] 4438
[postgres@lxicbpgdsgv01 ~]$

**** I have forgot use -v (verbose option to get extra output)
nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/pg_basebackup_lxicbpgdsgv01_10sep2025 -Ft -Xs -P -v > /pgBackup/pgsql17/backup/pg_basebackup_lxicbpgdsgv01_10sep2025.log 2>&1 &

9. Verify Backup


[postgres@lxicbpgdsgv01 ~]$ cat /pgBackup/pgsql17/backup/pg_basebackup_lxicbpgdsgv01_10sep2025.log
nohup: ignoring input
waiting for checkpoint
133816/536026 kB (24%), 0/1 tablespace
299960/536026 kB (55%), 0/1 tablespace
447864/536026 kB (83%), 0/1 tablespace
536037/536037 kB (100%), 0/1 tablespace
536037/536037 kB (100%), 1/1 tablespace
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ ls -lrth /pgBackup/pgsql17/backup/pg_basebackup_lxicbpgdsgv01_10sep2025
total 540M
-rw-------. 1 postgres postgres 524M Oct  9 18:56 base.tar  
-rw-------. 1 postgres postgres 223K Oct  9 18:56 backup_manifest
-rw-------. 1 postgres postgres  17M Oct  9 18:56 pg_wal.tar 
[postgres@lxicbpgdsgv01 ~]$

10. Transfer Backup to Target


[postgres@lxicbpgdsgv01 pg_basebackup_lxicbpgdsgv01_10sep2025]$ scp * 192.168.2.52:/pgbackup/pgsql17/backup/
postgres@192.168.2.52's password:  
backup_manifest                   100%  222KB  30.7MB/s   00:00
base.tar                          100%  523MB  74.0MB/s   00:07
pg_wal.tar                        100%   16MB  43.5MB/s   00:00
[postgres@lxicbpgdsgv01 pg_basebackup_lxicbpgdsgv01_10sep2025]$

11. Prepare Target & Restore

-- List Source Backup files 
[postgres@lxicbpgdsgv02 ~]$ ls -lrth /pgbackup/pgsql17/backup
total 540M
-rw-------. 1 postgres postgres 223K Oct  9 19:08 backup_manifest
-rw-------. 1 postgres postgres 524M Oct  9 19:08 base.tar
-rw-------. 1 postgres postgres  17M Oct  9 19:08 pg_wal.tar
[postgres@lxicbpgdsgv02 ~]$

11.1 Backup Target (Optional)


nohup pg_basebackup -U postgres -D /pgbackup/pgsql17/pg_basebackup_lxicbpgdsgv02_10sep2025 -Ft -Xs -P > /pgbackup/pgsql17/pg_basebackup_lxicbpgdsgv02_10sep2025.log 2>&1 &

-- Verify Tablespaces path -- It's pg_default in our case
-- Verify WAL File (Redo log files) location 

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/pg_wal
lrwxrwxrwx. 1 postgres postgres 18 Oct  9 17:37 /pgdata/pgsql17/data/pg_wal -> /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$

11.2 Stop PostgreSQL and Clean Directories

-- Stop PostgreSQL DB Cluster
[root@lxicbpgdsgv02 ~]# systemctl stop postgresql-17.service
[root@lxicbpgdsgv02 ~]#
[root@lxicbpgdsgv02 ~]# ps -ef | grep postgres
root       10259    7832  0 19:20 pts/0    00:00:00 grep --color=auto postgres
[root@lxicbpgdsgv02 ~]#

-- Remove all from Data directory 

[postgres@lxicbpgdsgv02 ~]$ rm -rf /pgdata/pgsql17/data/*
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data/
total 0
[postgres@lxicbpgdsgv02 ~]$


-- Remove all from WAL directory 

[postgres@lxicbpgdsgv02 ~]$ rm -rf /pgwal/pgsql17/wal/*
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgwal/pgsql17/wal/
total 0
[postgres@lxicbpgdsgv02 ~]$

11.3 Restore Data and WAL

-- List source backup files

[postgres@lxicbpgdsgv02 ~]$ cd /pgbackup/pgsql17/backup/
[postgres@lxicbpgdsgv02 backup]$ ls -ltr
total 552652
-rw-------. 1 postgres postgres    227724 Oct  9 19:08 backup_manifest
-rw-------. 1 postgres postgres 548901888 Oct  9 19:08 base.tar
-rw-------. 1 postgres postgres  16778752 Oct  9 19:08 pg_wal.tar
drwxr-xr-x. 3 postgres postgres        18 Oct  9 19:32 data_lxicbpgdsgv02_old
[postgres@lxicbpgdsgv02 backup]$

# Restore DATA Directory 
[postgres@lxicbpgdsgv02 ~]$ nohup tar -xvf /pgbackup/pgsql17/backup/base.tar -C /pgdata/pgsql17/data > /pgbackup/pgsql17/backup/base_restore.log 2>&1 &
[1] 11289
[postgres@lxicbpgdsgv02 ~]$


# Restore WAL Directory 

[postgres@lxicbpgdsgv02 ~]$ nohup tar -xvf /pgbackup/pgsql17/backup/pg_wal.tar -C /pgwal/pgsql17/wal > /pgbackup/pgsql17/backup/pg_wal_restore.log 2>&1 &
[1] 11304
[postgres@lxicbpgdsgv02 ~]$

-- OR -- 

# Restore base and WAL archives sequentially in a single command

nohup bash -c "tar -xvf /pgbackup/pgsql17/backup/base.tar -C /pgdata/pgsql17/data && tar -xvf /pgbackup/pgsql17/backup/pg_wal.tar -C /pgwal/pgsql17/wal" > /pgbackup/pgsql17/backup/fulltar_restore.log 2>&1 &

11.4 Set Permissions

[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgdata/pgsql17/data
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgdata/pgsql17/data
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ chown -R postgres:postgres /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$ chmod 700 /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$

11.5 Verify Restored Files

[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgdata/pgsql17/data
total 72
-rw-------. 1 postgres postgres    88 Sep 30 21:50 postgresql.auto.conf
drwx------. 2 postgres postgres    18 Sep 30 21:50 pg_xact
-rw-------. 1 postgres postgres     3 Sep 30 21:50 PG_VERSION
drwx------. 2 postgres postgres     6 Sep 30 21:50 pg_twophase
drwx------. 2 postgres postgres     6 Sep 30 21:50 pg_tblspc
drwx------. 2 postgres postgres     6 Sep 30 21:50 pg_subtrans
drwx------. 2 postgres postgres     6 Sep 30 21:50 pg_stat_tmp
drwx------. 2 postgres postgres     6 Sep 30 21:50 pg_snapshots
drwx------. 2 postgres postgres     6 Sep 30 21:50 pg_serial
drwx------. 2 postgres postgres     6 Sep 30 21:50 pg_notify
drwx------. 4 postgres postgres    36 Sep 30 21:50 pg_multixact
-rw-------. 1 postgres postgres  2640 Sep 30 21:50 pg_ident.conf
drwx------. 2 postgres postgres     6 Sep 30 21:50 pg_dynshmem
drwx------. 2 postgres postgres     6 Sep 30 21:50 pg_commit_ts
-rw-------. 1 postgres postgres 30702 Oct  7 18:20 postgresql.conf.bkp
drwx------. 2 postgres postgres    84 Oct  9 00:01 log
-rw-------. 1 postgres postgres  1169 Oct  9 16:31 postgresql.conf.bkp_10sep2025
-rw-------. 1 postgres postgres  1171 Oct  9 16:32 postgresql.conf
drwx------. 7 postgres postgres    59 Oct  9 18:08 base
drwx------. 2 postgres postgres     6 Oct  9 18:44 pg_stat
-rw-------. 1 postgres postgres    30 Oct  9 18:44 current_logfiles
-rw-------. 1 postgres postgres  5600 Oct  9 18:53 pg_hba.conf
-rw-------. 1 postgres postgres     0 Oct  9 18:56 tablespace_map
drwx------. 2 postgres postgres     6 Oct  9 18:56 pg_replslot
drwx------. 4 postgres postgres    68 Oct  9 18:56 pg_logical
-rw-------. 1 postgres postgres   227 Oct  9 18:56 backup_label
drwx------. 4 postgres postgres    45 Oct  9 20:06 pg_wal <--- Created as Directory, instead of symbolic link 
drwx------. 2 postgres postgres  4096 Oct  9 20:06 global
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ls -ltr /pgwal/pgsql17/wal
total 16384
-rw-------. 1 postgres postgres 16777216 Oct  9 18:56 000000010000000000000045
[postgres@lxicbpgdsgv02 ~]$

Please note:

--- Want symlinks preserved → use -Fp
--- Want single tar archive → use -Ft, but recreate symlinks after restore, for pg_wal

11.6 Create Symbolic Link for WAL

[postgres@lxicbpgdsgv02 ~]$ ls -ld /pgdata/pgsql17/data/pg_wal
drwx------. 4 postgres postgres 45 Oct  9 20:06 /pgdata/pgsql17/data/pg_wal
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ rm -rf /pgdata/pgsql17/data/pg_wal
[postgres@lxicbpgdsgv02 ~]$ ln -s /pgwal/pgsql17/wal /pgdata/pgsql17/data/pg_wal
[postgres@lxicbpgdsgv02 ~]$
[postgres@lxicbpgdsgv02 ~]$ ls -ld /pgdata/pgsql17/data/pg_wal
lrwxrwxrwx. 1 postgres postgres 18 Oct  9 21:04 /pgdata/pgsql17/data/pg_wal -> /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 ~]$ 
[postgres@lxicbpgdsgv02 ~]$ cd /pgwal/pgsql17/wal
[postgres@lxicbpgdsgv02 wal]$ ll
total 16384
-rw-------. 1 postgres postgres 16777216 Oct  9 18:56 000000010000000000000045
[postgres@lxicbpgdsgv02 wal]$

12. Start PostgreSQL on Target — no recovery needed.

[root@lxicbpgdsgv02 ~]# systemctl start postgresql-17.service
[root@lxicbpgdsgv02 ~]# systemctl status postgresql-17.service
● postgresql-17.service - PostgreSQL 17 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-17.service; enabled; preset: disabled)
     Active: active (running) since Thu 2025-10-09 21:06:08 +08; 5s ago
       Docs: https://www.postgresql.org/docs/17/static/
    Process: 12375 ExecStartPre=/usr/pgsql-17/bin/postgresql-17-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 12380 (postgres)
      Tasks: 7 (limit: 20496)
     Memory: 33.6M
        CPU: 114ms
     CGroup: /system.slice/postgresql-17.service
             ├─12380 /usr/pgsql-17/bin/postgres -D /pgdata/pgsql17/data
             ├─12381 "postgres: logger "
             ├─12382 "postgres: checkpointer "
             ├─12383 "postgres: background writer "
             ├─12385 "postgres: walwriter "
             ├─12386 "postgres: autovacuum launcher "
             └─12387 "postgres: logical replication launcher "

Oct 09 21:06:06 lxicbpgdsgv02.rajasekhar.com systemd[1]: Starting PostgreSQL 17 database server...
Oct 09 21:06:06 lxicbpgdsgv02.rajasekhar.com postgres[12380]: 2025-10-09 21:06:06.781 +08 [12380] LOG:  redirecting log output to logging collector process
Oct 09 21:06:06 lxicbpgdsgv02.rajasekhar.com postgres[12380]: 2025-10-09 21:06:06.781 +08 [12380] HINT:  Future log output will appear in directory "log".
Oct 09 21:06:08 lxicbpgdsgv02.rajasekhar.com systemd[1]: Started PostgreSQL 17 database server.
[root@lxicbpgdsgv02 ~]#

13. Final Verification

[postgres@lxicbpgdsgv02 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# \l+
                                                                                       List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | Locale | ICU Rules |   Access privileges   |  Size   | Tablespace |                Description
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------+---------+------------+--------------------------------------------
 dell      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7609 kB | pg_default |
 orcl      | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 7753 kB | pg_default |
 postgres  | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           |                       | 492 MB  | pg_default | default administrative connection database
 template0 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7545 kB | pg_default | unmodifiable empty database
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |            |
 template1 | postgres | UTF8     | libc            | en_SG.UTF-8 | en_SG.UTF-8 |        |           | =c/postgres          +| 7569 kB | pg_default | default template for new databases
           |          |          |                 |             |             |        |           | postgres=CTc/postgres |         |            |
(5 rows)

postgres=# \db
       List of tablespaces
    Name    |  Owner   | Location
------------+----------+----------
 pg_default | postgres |
 pg_global  | postgres |
(2 rows)

postgres=#
postgres=# \c dell
You are now connected to database "dell" as user "postgres".
dell=# \dt test.*
        List of relations
 Schema | Name | Type  |  Owner
--------+------+-------+----------
 test   | emp  | table | postgres
(1 row)

dell=#

dell=# select * from test.emp;  <---- We can see Data 
 name | designation | project | company
------+-------------+---------+---------
 Sugi | DBA         | Jetstar | iGATE
 Teja | DBA         | RCM     | iGATE
 RAJ  | DBA         | RCM     | iGATE
(3 rows)

dell=#
dell=# \c orcl
You are now connected to database "orcl" as user "postgres".
orcl=# \dt
            List of relations
 Schema |    Name     | Type  |  Owner
--------+-------------+-------+----------
 public | sample_data | table | postgres
(1 row)

orcl=#
orcl=# select count(*) from sample_data;
 count
-------
  1000 <----
(1 row)

orcl=#

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

Disable ARCHIVELOG Mode

How to Disable ARCHIVELOG Mode

Table of Contents


1. Verify Existing Archive Mode
2. Edit the archive settings
3. Restart PostgreSQL
4. Verify Current Mode
5. Verify WAL Archiving Behavior


1. Verify Existing Archive Mode

postgres=# SHOW archive_mode;
 archive_mode
--------------
 on  <------ 
(1 row)

postgres=#

postgres=# SHOW archive_command;
        archive_command
-------------------------------
 cp %p /pgArch/pgsql17/arch/%f  <----- 
(1 row)

postgres=#

2. Edit the archive settings


[postgres@lxicbpgdsgv01 ~]$ cp /pgData/pgsql17/data/postgresql.conf /pgData/pgsql17/data/postgresql.conf.bkp_10sep2025
[postgres@lxicbpgdsgv01 ~]$ vi /pgData/pgsql17/data/postgresql.conf

#archive_mode = on
#archive_command = 'cp %p /pgArch/pgsql17/arch/%f'

3. Restart PostgreSQL

[root@lxicbpgdsgv01 ~]# systemctl stop postgresql-17.service
[root@lxicbpgdsgv01 ~]#
[root@lxicbpgdsgv01 ~]# systemctl start  postgresql-17.service
[root@lxicbpgdsgv01 ~]#
[root@lxicbpgdsgv01 ~]# systemctl status postgresql-17.service
● postgresql-17.service - PostgreSQL 17 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-17.service; enabled; preset: disabled)
     Active: active (running) since Thu 2025-10-09 16:34:01 +08; 3s ago
       Docs: https://www.postgresql.org/docs/17/static/
    Process: 3492 ExecStartPre=/usr/pgsql-17/bin/postgresql-17-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 3497 (postgres)
      Tasks: 7 (limit: 15835)
     Memory: 17.6M
        CPU: 92ms
     CGroup: /system.slice/postgresql-17.service
             ├─3497 /usr/pgsql-17/bin/postgres -D /pgData/pgsql17/data/
             ├─3498 "postgres: logger "
             ├─3499 "postgres: checkpointer "
             ├─3500 "postgres: background writer "
             ├─3502 "postgres: walwriter "
             ├─3503 "postgres: autovacuum launcher "
             └─3504 "postgres: logical replication launcher "

Oct 09 16:34:01 lxicbpgdsgv01.rajasekhar.com systemd[1]: Starting PostgreSQL 17 database server...
Oct 09 16:34:01 lxicbpgdsgv01.rajasekhar.com postgres[3497]: 2025-10-09 16:34:01.929 +08 [3497] LOG:  redirecting log output to logging collector process
Oct 09 16:34:01 lxicbpgdsgv01.rajasekhar.com postgres[3497]: 2025-10-09 16:34:01.929 +08 [3497] HINT:  Future log output will appear in directory "log".
Oct 09 16:34:01 lxicbpgdsgv01.rajasekhar.com systemd[1]: Started PostgreSQL 17 database server.
[root@lxicbpgdsgv01 ~]#

4. Verify Current Mode

[postgres@lxicbpgdsgv01 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# SHOW archive_mode;
 archive_mode
--------------
 off  <------ it's disabled
(1 row)

postgres=# SHOW archive_command;
 archive_command
-----------------
 (disabled) <-------
(1 row)

postgres=#

5. Verify WAL Archiving Behavior


postgres=# CHECKPOINT;
CHECKPOINT
postgres=#
postgres=# CHECKPOINT;
CHECKPOINT
postgres=# CHECKPOINT;
CHECKPOINT
postgres=#
postgres=# exit
postgres=# SELECT pg_switch_wal();
 pg_switch_wal
---------------
 0/44000000
(1 row)

postgres=# SELECT pg_switch_wal();
 pg_switch_wal
---------------
 0/44000000
(1 row)

postgres=# SELECT pg_switch_wal();
 pg_switch_wal
---------------
 0/44000000
(1 row)

postgres=#
[postgres@lxicbpgdsgv01 ~]$ ls -ltr /pgArch/pgsql17/arch/
total 0  <---- Archivelogs not generating
[postgres@lxicbpgdsgv01 ~]$

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

pg_basebackup

pg_basebackup – Backup, Restore, and Recovery

What is pg_basebackup?

pg_basebackup is a utility provided by PostgreSQL to take a physical base backup of the entire database cluster.

Common Use Cases:

  • Setting up standby servers for streaming replication
  • Creating physical backups for disaster recovery
  • Performing Point-In-Time Recovery (PITR)
  • Performing Incremental Backups (PostgreSQL v17 feature)

It connects to a running PostgreSQL server and copies all necessary data files and WAL segments, producing a consistent and restorable backup.

———- Backup ———-

Pre-requisites parameter and config:

      1. User : Requires a user with replication role or superuser privileges
CREATE ROLE repl_user WITH REPLICATION LOGIN ENCRYPTED PASSWORD 'replpass';
     2. postgresql.conf
  • wal_level=replica  (Mandatory)
  • max_wal_senders >=1 (Mandatory)
  • archive_mode=on (Optional if Database in NO Archivelog mode)
  • archive_command = ‘cp %p /pgArch/pgsql17/arch/%f’ (Optional if Database in NO Archivelog mode)
      3. pg_hba.conf
# TYPE  DATABASE        USER            ADDRESS             METHOD
# Local connections for replication (for pg_basebackup run locally)
local   replication     all                                 trust

# or you can use peer (if same OS user postgres is used)
# local   replication     all                                 peer

# Remote connections for replication (for pg_basebackup run remotely)
host    replication     repl_user       192.168.2.22/32     scram-sha-256

How pg_basebackup Works Internally:

Featurepg_basebackup Supports?
Backup of data directoryYes
Include enough WALs to make backup consistentYes
Backup of WAL archives (even with archive mode=on & archive_command configured)No
Works without archive_modeYes
  • Performs a physical file-level backup by copying the full data directory
  • Uses PostgreSQL’s streaming replication protocol
  • Requires a user with replication role or superuser privileges
  • Can be used while the server is running (online backup)
  • Ensures a transactionally consistent snapshot of the database
  • Even with archive_mode=on and archive_command configured, pg_basebackup does not back up WAL archive logs from the archive location. It only includes enough live WAL files to make the backup consistent, streamed from pg_wal/.
  • pg_basebackup does not include all files from the pg_wal directory in the backup.
    Instead, it selectively includes only the WAL files required to make the base backup consistent at the point in time the backup was taken.

What It Includes:

  • All essential data files of the cluster
  • Necessary WAL (Write-Ahead Log) segments for recovery
  • Custom tablespaces, replication slots, and large objects

WAL Handling Options:

  • Default: WAL files included after backup (-X fetch)
  • Streaming: WAL files streamed live during backup (-X stream)

How to take Backup using pg_basebackup ?

  • Want symlinks preserved → use (both -Fp & –waldir)-Fp --waldir=/pgWal/pgsql17/wal
  • Want single tar archive → use -Ft, but recreate symlinks after restore, for pg_wal
  • The –waldir option in pg_basebackup is supported only when using the plain format (-Fp), not with the tar format (-Ft).
-- Do not use -R here since it's not a replica (No standby).

Typically Backup using: Plain format, Tar format & Tar format (gzip)

1. Take backup in Plain format
nohup pg_basebackup -U postgres -D /pgBackups/pgsql17/demo_restore -Fp -Xs -P -v > pg_basebackup_demo_restore.log 2>&1 &

2. Take backup in Tar format
nohup pg_basebackup -U postgres -D /pgBackups/pgsql17/demo_tar_backup -Ft -Xs -P -v > pg_basebackup_tar.log 2>&1 &

3. Take backup in Compressed Tar format (gzip)
nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/ -Ft -z -Xs -P -v > pg_basebackup_tar.log 2>&1 &

4. Take compressed Tar backup with transfer rate limit
nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/ -Ft -z -X stream -P --max-rate=5M -v > pg_basebackup_tar.log 2>&1 &

5. Take compressed Tar backup with server-side gzip compression at max level (9)
nohup pg_basebackup -U postgres -D /pgBackup/pgsql17/backup/ -Ft --compress=server-gzip:9 -Xs -P -v > pg_basebackup.log 2>&1 &

6. Take Tar backup from a remote host
nohup pg_basebackup -h remote_host -p port -U postgres -D /pgBackup/remote_tar_backup -Ft -Xs -P -v > pg_basebackup_remote_tar.log 2>&1 &
PG BASE BACKUP FlagDescription
-U <username>Specifies the PostgreSQL user to connect as.
-D <directory>Specifies the target directory for the backup.
-F pTakes the backup in Plain format (file system copy).
-F tTakes the backup in Tar archive format.
-zCompresses the backup using gzip compression (only valid with tar format).
--compress=server-gzip:<level>Enables server-side gzip compression with specified compression level (1-9).
-X sIncludes the Write-Ahead Log (WAL) files by copying the WAL segment files.
-X streamStreams the WAL files while taking the backup for continuous consistency.
-PShows progress information during the backup.
--max-rate=<rate>Limits the maximum transfer rate during the backup (e.g., 5M for 5 megabytes/sec).
-v–verbose, extra output

———- Restore ———-

1. Restore is a File-Level Operation

A base backup is a physical copy of the database files — including system catalogs, user data, WAL files, and optionally config files.
Restoring is done by simply copying or extracting the backup files into a valid PostgreSQL data directory (PGDATA) on the target system.

Restore Steps:

  1. Stop PostgreSQL (if running)
  2. Copy or extract the backup into a clean data directory (PGDATA)
  3. Place a file named recovery.signal in the data directory
  4. Start PostgreSQL to begin recovery

2. Custom Tablespaces Outside PGDATA

  • Backups include symlinks to external tablespace locations
  • On restore:
    • Ensure original paths exist and are accessible
    • Or remap symlinks to new locations
    • Check ownership and permissions (postgres:postgres, 0700)

3. Restoring on a Different Host

  • Ensure matching directory structure or adjust accordingly
  • PostgreSQL version and architecture must match
  • Update postgresql.conf and pg_hba.conf as needed

4. Restoring Across PostgreSQL Versions

pg_basebackup is version-specific.

  • Not allowed: PostgreSQL 14 → PostgreSQL 15 or 17 (Lower to Higher)
  • Not allowed: PostgreSQL 17 → PostgreSQL 14 (Higher to Lower)
  • Use pg_dump/pg_restore or pg_upgrade for version upgrades

———- Recovery ———-

How Recovery Works:

  1. PostgreSQL detects recovery.signal at startup
  2. WAL files (in pg_wal/ or archive) are replayed (Redo apply / Archive apply  from restore_command location )
  3. When recovery completes:
    • PostgreSQL automatically removes recovery.signal
    • The server becomes a primary (read/write)
  4. Recovery stops when:
    • All available WALs are applied, or
    • A recovery target (e.g., timestamp, transaction ID) is reached

What is recovery.signal ?

FilePurpose
recovery.signalTells PostgreSQL to enter recovery mode during startup
Automatically removed?Yes, after recovery completes
Required for standalone restore?Yes, otherwise WAL replay is skipped

Summary 

1. Take a base backup on the source server using ‘pg_basebackup’.
2. Take Backup of WAL Archive files separately on Source (Manually, because pg_basebackup does NOT take backup of WAL archive files)
3. Transfer both the base backup and WAL archive logs to the target server.
4. Restore the base backup to the PostgreSQL data directory on the target.
5. Copy the WAL files to the dedicated WAL location (e.g., ‘/pgwal/pgsql17/wals’).
6. Remove ‘$PGDATA/pg_wal’ and create a symbolic link to the WAL location:
‘ln -s /pgwal/pgsql17/wals /pgdata/pgsql17/data/pg_wal’
7. Create an empty ‘recovery.signal‘ file in ‘$PGDATA’.
8. Set ‘restore_command‘ in ‘postgresql.conf’ to point to WAL archive backup path (e.g., ‘/pgbackup/pgsql17/backup/wal_archive_bkp’).
9. Ensure WAL archive files are restored to ‘/pgbackup/pgsql17/backup/wal_archive_bkp’ for ‘restore_command’ to access.
10. Update ‘tablespace_map‘ to reflect correct paths if using custom tablespaces.
11. Start PostgreSQL on the target; recovery will complete and automatically remove ‘recovery.signal’.
12. Tablespace symbolic links will create automatically by PostgreSQL.

OperationKey Point
BackupFile-level copy using replication protocol
RestorePlace files into PGDATA, handle symlinks, configs, and versions
RecoveryTriggered by recovery.signal, replays WAL, auto-removes signal file

 

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

Change PostgreSQL WAL Directory Path (pg_wal)

Table of Contents


0. Aim
1. Verify Existing pg_wal Directory
2. Create the New Directory
3. Stop PostgreSQL Service
4. Copy WAL Files to New Location
5. Backup Old WAL Directory
6. Create Symlink
7. Fix Permissions
8. Start PostgreSQL Service
9. Verify WAL Functionality
10. Remove Old WAL Directory (Optional)


0. Aim

To change the PostgreSQL 17 WAL File directory from its default location to new mount point

From : /var/lib/pgsql/17/data

TO : /pgData/pgsql17/data

1. Verify Existing pg_wal directory


[postgres@lxicbpgdsgv01 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# SELECT current_setting('data_directory') || '/pg_wal' AS wal_directory;
        wal_directory
-----------------------------
 /pgData/pgsql17/data/pg_wal  <----- 
(1 row)

postgres=# exit
[postgres@lxicbpgdsgv01 ~]$ ls -lrth /pgData/pgsql17/data/pg_wal
total 48M
drwx------. 2 postgres postgres   6 Sep 30 21:50 summaries
-rw-------. 1 postgres postgres 16M Oct  8 04:24 000000010000000000000008
-rw-------. 1 postgres postgres 16M Oct  8 16:08 000000010000000000000006
-rw-------. 1 postgres postgres 16M Oct  8 16:08 000000010000000000000007
drwx------. 2 postgres postgres  43 Oct  8 16:08 archive_status
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ du -sh /pgData/pgsql17/data/pg_wal
48M     /pgData/pgsql17/data/pg_wal
[postgres@lxicbpgdsgv01 ~]$

2. Create the New Directory on a new disk

[root@lxicbpgdsgv01 ~]# mkdir -p /pgData/pgsql17/data
[root@lxicbpgdsgv01 ~]# chown postgres:postgres /pgData/pgsql17/data
[root@lxicbpgdsgv01 ~]# chmod 700 /pgData/pgsql17/data
[root@lxicbpgdsgv01 ~]#

3. Stop PostgreSQL Service

[root@lxicbpgdsgv01 ~]# systemctl stop postgresql-17.service
[root@lxicbpgdsgv01 ~]#
[root@lxicbpgdsgv01 ~]# ps -ef | grep postgres
root        6887    6721  0 16:08 pts/0    00:00:00 grep --color=auto postgres
[root@lxicbpgdsgv01 ~]#

4. Copy Existing WAL Files to New Location

[postgres@lxicbpgdsgv01 ~]$ nohup rsync -avh --progress /pgData/pgsql17/data/pg_wal/ /pgWal/pgsql17/wal/ > rsync_pgwal.log 2>&1 &
[1] 6943
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$
[1]+  Done                    nohup rsync -avh --progress /pgData/pgsql17/data/pg_wal/ /pgWal/pgsql17/wal/ > rsync_pgwal.log 2>&1
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ cat rsync_pgwal.log
nohup: ignoring input
sending incremental file list
./
000000010000000000000006
         16.78M 100%   81.89MB/s    0:00:00 (xfr#1, to-chk=5/7)
000000010000000000000007
         16.78M 100%   43.84MB/s    0:00:00 (xfr#2, to-chk=4/7)
000000010000000000000008
         16.78M 100%   31.07MB/s    0:00:00 (xfr#3, to-chk=3/7)
archive_status/
archive_status/000000010000000000000006.done
              0 100%    0.00kB/s    0:00:00 (xfr#4, to-chk=0/7)
summaries/

sent 50.34M bytes  received 107 bytes  33.56M bytes/sec
total size is 50.33M  speedup is 1.00
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ ls -lrth /pgWal/pgsql17/wal/
total 48M
drwx------. 2 postgres postgres   6 Sep 30 21:50 summaries
-rw-------. 1 postgres postgres 16M Oct  8 04:24 000000010000000000000008
-rw-------. 1 postgres postgres 16M Oct  8 16:08 000000010000000000000006
-rw-------. 1 postgres postgres 16M Oct  8 16:08 000000010000000000000007
drwx------. 2 postgres postgres  43 Oct  8 16:08 archive_status
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ du -sh /pgWal/pgsql17/wal/
48M     /pgWal/pgsql17/wal/
[postgres@lxicbpgdsgv01 ~]$

5. Move old directory as backup

[postgres@lxicbpgdsgv01 ~]$ mv /pgData/pgsql17/data/pg_wal /pgData/pgsql17/data/pg_wal.bak
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ ls -ld /pgData/pgsql17/data/pg_wal
ls: cannot access '/pgData/pgsql17/data/pg_wal': No such file or directory
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ ls -ld /pgData/pgsql17/data/pg_wal.bak
drwx------. 4 postgres postgres 141 Oct  8 16:08 /pgData/pgsql17/data/pg_wal.bak
[postgres@lxicbpgdsgv01 ~]$

6. Create symlink

[postgres@lxicbpgdsgv01 ~]$ ln -s /pgWal/pgsql17/wal /pgData/pgsql17/data/pg_wal
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ ls -ltr /pgData/pgsql17/data/pg_wal
lrwxrwxrwx. 1 postgres postgres 18 Oct  8 16:16 /pgData/pgsql17/data/pg_wal -> /pgWal/pgsql17/wal
[postgres@lxicbpgdsgv01 ~]$

7. Fix permissions (if required)

[postgres@lxicbpgdsgv01 ~]$ chown -R postgres:postgres /pgWal/pgsql17/wal

8. Start PostgreSQL Service

[root@lxicbpgdsgv01 ~]# systemctl start postgresql-17.service
[root@lxicbpgdsgv01 ~]#
[root@lxicbpgdsgv01 ~]# systemctl status postgresql-17.service
● postgresql-17.service - PostgreSQL 17 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-17.service; enabled; preset: disabled)
     Active: active (running) since Wed 2025-10-08 16:20:46 +08; 7s ago
       Docs: https://www.postgresql.org/docs/17/static/
    Process: 7079 ExecStartPre=/usr/pgsql-17/bin/postgresql-17-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 7084 (postgres)
      Tasks: 8 (limit: 15835)
     Memory: 18.1M
        CPU: 94ms
     CGroup: /system.slice/postgresql-17.service
             ├─7084 /usr/pgsql-17/bin/postgres -D /pgData/pgsql17/data/
             ├─7086 "postgres: logger "
             ├─7087 "postgres: checkpointer "
             ├─7088 "postgres: background writer "
             ├─7090 "postgres: walwriter "
             ├─7091 "postgres: autovacuum launcher "
             ├─7092 "postgres: archiver "
             └─7093 "postgres: logical replication launcher "

Oct 08 16:20:46 lxicbpgdsgv01.rajasekhar.com systemd[1]: Starting PostgreSQL 17 database server...
Oct 08 16:20:46 lxicbpgdsgv01.rajasekhar.com postgres[7084]: 2025-10-08 16:20:46.162 +08 [7084] LOG:  redirecting log output to logging collector process
Oct 08 16:20:46 lxicbpgdsgv01.rajasekhar.com postgres[7084]: 2025-10-08 16:20:46.162 +08 [7084] HINT:  Future log output will appear in directory "log".
Oct 08 16:20:46 lxicbpgdsgv01.rajasekhar.com systemd[1]: Started PostgreSQL 17 database server.
[root@lxicbpgdsgv01 ~]#

9. Verify

-- Load WAL File generation (Testing)

postgres=# -- Create test table
DROP TABLE IF EXISTS wal_test;
CREATE TABLE wal_test (
    id serial PRIMARY KEY,
    data text
);

-- Generate WAL traffic
DO $$
DECLARE
    i integer;
BEGIN
    FOR i IN 1..50 LOOP
        -- INSERT: 10,000 rows
        INSERT INTO wal_test (data)
        SELECT repeat('wal_test_data_', 50)
        FROM generate_series(1, 10000);

        -- UPDATE: 5,000 rows using CTE with LIMIT
        WITH to_update AS (
            SELECT id FROM wal_test WHERE id % 2 = 0 LIMIT 5000
        )
        UPDATE wal_test
        SET data = data || '_updated'
        WHERE id IN (SELECT id FROM to_update);

        -- DELETE: 5,000 rows using CTE with LIMIT
        WITH to_delete AS (
            SELECT id FROM wal_test WHERE id % 3 = 0 LIMIT 5000
        )
        DELETE FROM wal_test
        WHERE id IN (SELECT id FROM to_delete);

        -- Commit to flush WAL
        COMMIT;

        -- Optional pause to slow down the loop
        PERFORM pg_sleep(0.5);
    END LOOP;
END$$;
DROP TABLE
CREATE TABLE
DO
postgres=# exit
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ ls -lrth  /pgWal/pgsql17/wal
total 752M
drwx------. 2 postgres postgres    6 Sep 30 21:50 summaries
-rw-------. 1 postgres postgres  16M Oct  8 16:34 000000010000000000000009
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000A
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000B
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000C
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000D
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000E
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000F
-rw-------. 1 postgres postgres  16M Oct  8 16:34 000000010000000000000010
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000011
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000012
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000013
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000014
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000015
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000016
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000017
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000018
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000019
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001A
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001B
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001C
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001D
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001E
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001F
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000020
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000021
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000022
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000023
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000024
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000025
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000026
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000027
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000028
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000029
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002A
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002B
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002C
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002D
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002E
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002F
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000030
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000031
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000032
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000033
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000034
-rw-------. 1 postgres postgres  16M Oct  8 16:36 000000010000000000000035
drwx------. 2 postgres postgres 4.0K Oct  8 16:36 archive_status
-rw-------. 1 postgres postgres  16M Oct  8 16:36 xlogtemp.7289
[postgres@lxicbpgdsgv01 ~]$

10. Remove Old WAL Directory (Optional, later)

[postgres@lxicbpgdsgv01 ~]$ ls -ld /pgData/pgsql17/data/pg_wal.bak
drwx------. 4 postgres postgres 141 Oct  8 16:08 /pgData/pgsql17/data/pg_wal.bak
[postgres@lxicbpgdsgv01 ~]$ rm -rf /pgData/pgsql17/data/pg_wal.bak
[postgres@lxicbpgdsgv01 ~]$

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

WAL Files

Understanding WAL Files in PostgreSQL – For Oracle DBAs

What is WAL?

WAL (Write-Ahead Logging) ensures data durability and crash recovery. Every change is first written to WAL before being flushed to data files. 

1. WAL Location: WAL files are stored in $PGDATA/pg_wal/.
2. Fixed Size: Each WAL segment is pre-allocated with a fixed size (typically 16MB), set at cluster initialization (initdb).
3. Writing & Switching: WAL segments are written sequentially. PostgreSQL switches to the next segment when the current one is full or a manual switch is triggered (e.g., via pg_switch_wal()).
4. WAL and Archive File Size: When archived, the exact same 16MB WAL segment file is copied as raw binary to the archive destination. Therefore, archive files always match the WAL segment size.
5. Archiving: If archive_mode = on, PostgreSQL uses the archive_command to copy completed WAL segments to the archive destination (e.g., /pgArch/...). Only full segments are archived.
6. Recycling: If archiving is disabled, PostgreSQL reuses old WAL segments once they’re no longer needed for recovery or replication.

WAL Files = Redo Log Files
WAL Archives = Archive Log Files

PostgreSQL vs Oracle Comparison

AspectOraclePostgreSQL
Redo Log FilesCalled Redo Log FilesCalled WAL Files
Archive Log FilesCalled Archive Log FilesCalled WAL Archives
Redo Log File Size~200MB (default)16MB (default and fixed)
Redo Log Files CountMinimum 2 or more redo log groups
(Best practice: 3)
No fixed number
Controlled by: min_wal_size / wal_segment_size
Example: 80MB / 16MB = 5 WAL files
Archive Log File Size~200MB (same as redo log file size)16MB (same as WAL file size)
Log File StorageRedo log files stored in redo log groupsWAL files stored in pg_wal directory
Archiving MechanismArchive logs created if archiving is enabledArchived via archive_command if archive_mode = on
Overwrite BehaviorRedo logs are overwritten when full (if archive not enabled)WAL segments are recycled/overwritten when full (if archive_mode is off)
Force Switch BehaviorALTER SYSTEM SWITCH LOGFILE;SELECT pg_switch_wal();

PostgreSQL WAL Configuration Parameters

ParameterMeaningDefault
wal_segment_sizeSize of each WAL file16MB
min_wal_sizeMinimum total WAL size retained80MB (5 WAL files)
Common in production: 8GB
max_wal_sizeMax WAL before triggering a checkpoint1GB
Common in production: 16GB

Check Configuration

[postgres@lxicbpgdsgv01 ~]$ psql -c "SHOW wal_segment_size;"
wal_segment_size
------------------
16MB  <----- Each redo log file size
(1 row)

[postgres@lxicbpgdsgv01 ~]$


[postgres@lxicbpgdsgv01 ~]$ psql -c "SHOW min_wal_size;"
 min_wal_size
--------------
 80MB <---- 80MB/16MB = 5 <--- Total 5 redo log files with each 16MB
(1 row)

[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ psql -c "SHOW max_wal_size;"
 max_wal_size
--------------
 1GB  <---- 1024MB
(1 row)

[postgres@lxicbpgdsgv01 ~]$

View WAL files (Redo log files)

postgres=# SELECT current_setting('data_directory') || '/pg_wal' AS wal_directory;
        wal_directory
-----------------------------
 /pgData/pgsql17/data/pg_wal  <---- Redo log file directory
(1 row)

postgres=# 
[postgres@lxicbpgdsgv01 ~]$ ls -lh /pgData/pgsql17/data/pg_wal | grep -E '^-.* [0-9]+ .* [0-9A-F]{24}$'
-rw-------. 1 postgres postgres 16M Oct 8 01:33 000000010000000000000005
-rw-------. 1 postgres postgres 16M Oct 8 01:28 000000010000000000000006
-rw-------. 1 postgres postgres 16M Oct 8 01:28 000000010000000000000007
[postgres@lxicbpgdsgv01 ~]$

min_wal_size = 80MB means PostgreSQL will try to keep at least 5 WAL segment files on disk (since 80MB ÷ 16MB = 5 files).

However, in our case, only 3 WAL files are currently present. This is likely because the system is under low load in the testing environment, so fewer WAL files are needed at the moment.

---- Lets Generate Load

postgres=# -- Create test table
DROP TABLE IF EXISTS wal_test;
CREATE TABLE wal_test (
    id serial PRIMARY KEY,
    data text
);

-- Generate WAL traffic
DO $$
DECLARE
    i integer;
BEGIN
    FOR i IN 1..50 LOOP
        -- INSERT: 10,000 rows
        INSERT INTO wal_test (data)
        SELECT repeat('wal_test_data_', 50)
        FROM generate_series(1, 10000);

        -- UPDATE: 5,000 rows using CTE with LIMIT
        WITH to_update AS (
            SELECT id FROM wal_test WHERE id % 2 = 0 LIMIT 5000
        )
        UPDATE wal_test
        SET data = data || '_updated'
        WHERE id IN (SELECT id FROM to_update);

        -- DELETE: 5,000 rows using CTE with LIMIT
        WITH to_delete AS (
            SELECT id FROM wal_test WHERE id % 3 = 0 LIMIT 5000
        )
        DELETE FROM wal_test
        WHERE id IN (SELECT id FROM to_delete);

        -- Commit to flush WAL
        COMMIT;

        -- Optional pause to slow down the loop
        PERFORM pg_sleep(0.5);
    END LOOP;
END$$;
DROP TABLE
CREATE TABLE
DO
postgres=# exit
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ 
ls -lrth /pgData/pgsql17/data/pg_wal
total 752M
drwx------. 2 postgres postgres    6 Sep 30 21:50 summaries
-rw-------. 1 postgres postgres  16M Oct  8 16:34 000000010000000000000009
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000A
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000B
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000C
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000D
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000E
-rw-------. 1 postgres postgres  16M Oct  8 16:34 00000001000000000000000F
-rw-------. 1 postgres postgres  16M Oct  8 16:34 000000010000000000000010
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000011
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000012
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000013
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000014
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000015
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000016
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000017
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000018
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000019
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001A
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001B
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001C
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001D
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001E
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000001F
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000020
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000021
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000022
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000023
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000024
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000025
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000026
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000027
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000028
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000029
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002A
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002B
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002C
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002D
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002E
-rw-------. 1 postgres postgres  16M Oct  8 16:35 00000001000000000000002F
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000030
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000031
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000032
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000033
-rw-------. 1 postgres postgres  16M Oct  8 16:35 000000010000000000000034
-rw-------. 1 postgres postgres  16M Oct  8 16:36 000000010000000000000035
drwx------. 2 postgres postgres 4.0K Oct  8 16:36 archive_status
-rw-------. 1 postgres postgres  16M Oct  8 16:36 xlogtemp.7289
[postgres@lxicbpgdsgv01 ~]$ 

-- Now We can see Many WAL Files (Redo log files) generated, count increased from 3 WAL files to 50+ WAL files

View Archived WAL Files (Archive log files)

postgres=# SHOW archive_command;
        archive_command
-------------------------------
 cp %p /pgArch/pgsql17/arch/%f
(1 row)

postgres=#

[postgres@lxicbpgdsgv01 ~]$ 
[postgres@lxicbpgdsgv01 ~]$ ls -lrth /pgArch/pgsql17/arch/
total 976M
-rw-------. 1 postgres postgres 16M Oct  7 23:50 000000010000000000000001
-rw-------. 1 postgres postgres 16M Oct  7 23:51 000000010000000000000002
-rw-------. 1 postgres postgres 16M Oct  8 01:28 000000010000000000000003
-rw-------. 1 postgres postgres 16M Oct  8 01:28 000000010000000000000004
-rw-------. 1 postgres postgres 16M Oct  8 04:24 000000010000000000000005
-rw-------. 1 postgres postgres 16M Oct  8 16:08 000000010000000000000006
-rw-------. 1 postgres postgres 16M Oct  8 16:24 000000010000000000000007
-rw-------. 1 postgres postgres 16M Oct  8 16:25 000000010000000000000008
-rw-------. 1 postgres postgres 16M Oct  8 16:34 000000010000000000000009
-rw-------. 1 postgres postgres 16M Oct  8 16:34 00000001000000000000000A
-rw-------. 1 postgres postgres 16M Oct  8 16:34 00000001000000000000000B
-rw-------. 1 postgres postgres 16M Oct  8 16:34 00000001000000000000000C
-rw-------. 1 postgres postgres 16M Oct  8 16:34 00000001000000000000000D
-rw-------. 1 postgres postgres 16M Oct  8 16:34 00000001000000000000000E
-rw-------. 1 postgres postgres 16M Oct  8 16:34 00000001000000000000000F
-rw-------. 1 postgres postgres 16M Oct  8 16:34 000000010000000000000010
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000011
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000012
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000013
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000014
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000015
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000016
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000017
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000018
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000019
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000001A
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000001B
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000001C
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000001D
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000001E
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000001F
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000020
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000021
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000022
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000023
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000024
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000025
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000026
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000027
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000028
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000029
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000002A
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000002B
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000002C
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000002D
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000002E
-rw-------. 1 postgres postgres 16M Oct  8 16:35 00000001000000000000002F
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000030
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000031
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000032
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000033
-rw-------. 1 postgres postgres 16M Oct  8 16:35 000000010000000000000034
-rw-------. 1 postgres postgres 16M Oct  8 16:36 000000010000000000000035
-rw-------. 1 postgres postgres 16M Oct  8 16:36 000000010000000000000036
-rw-------. 1 postgres postgres 16M Oct  8 16:36 000000010000000000000037
-rw-------. 1 postgres postgres 16M Oct  8 16:36 000000010000000000000038
-rw-------. 1 postgres postgres 16M Oct  8 16:36 000000010000000000000039
-rw-------. 1 postgres postgres 16M Oct  8 16:36 00000001000000000000003A
-rw-------. 1 postgres postgres 16M Oct  8 16:36 00000001000000000000003B
-rw-------. 1 postgres postgres 16M Oct  8 16:36 00000001000000000000003C
-rw-------. 1 postgres postgres 16M Oct  8 16:36 00000001000000000000003D
[postgres@lxicbpgdsgv01 ~]$

-- WAL and Archive File Size: When archived, the exact same 16MB WAL segment file is copied as raw binary to the archive destination. Therefore, archive files always match the WAL segment size (redo log size). 

Best Practices

  • Use a dedicated mount point for pg_wal (WAL directory) – eg. /pgWal
  • Set min_wal_size to higher value in production (e.g. 8GB)
  • Keep WAL archive files on a separate mount point for better I/O and space isolation – eg. /pgArch
  • Monitor WAL archive directory regularly to avoid disk full errors

Note:

  • WAL file size is fixed at cluster init (default: 16MB). You cannot change it for an existing cluster.
  • PostgreSQL WAL Size Be Can Increased only at NEW cluster creation time via initdb (64MB)
    /usr/pgsql-17/bin/initdb –wal-segsize=64 -D /pgData/pgsql17/data

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

Enable Archive Mode (WAL Archiving)

Enable Archive Mode in PostgreSQL 17


Table of Contents

0. Importance of Archive Log Files
1. Verify Existing Archive Mode
2. Ensure Archive Directory Exists
3. Edit postgresql.conf
4. Restart PostgreSQL
5. Verify the Configuration
6. Test Archiving Works


0. Importance of Archive Log Files

Archive log files, also known as WAL archives (Write-Ahead Log archives) , play a critical role in PostgreSQL for data protection, recovery, and replication.

A. Point-in-Time Recovery (PITR): Restore the database to a specific point in time, useful for accidental data changes or loss.
B. Continuous Backup: Works with base backups to enable robust disaster recovery.
C. Streaming Replication Support: Helps standby servers catch up if they fall behind.
D. Disaster Recovery: Enables full recovery after hardware or data corruption.
E. Data Audit & Analysis: Allows decoding WAL logs for auditing and compliance.

🛑 Important Note:

If WAL archiving is disabled and a backup is taken, you can only restore to the exact backup time, not to any point after.

1. Verify Existing Archive Mode

[postgres@lxicbpgdsgv01 ~]$ psql
psql (17.6)
Type "help" for help.

postgres=# SHOW archive_mode;
 archive_mode 
--------------
 off <--- it's off
(1 row)

postgres=# SHOW archive_command;
 archive_command 
-----------------
 (disabled) <----
(1 row)
[root@lxicbpgdsgv01 ~]# systemctl status postgresql-17
● postgresql-17.service - PostgreSQL 17 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-17.service; enabled; preset: disabled)
     Active: active (running) since Tue 2025-10-07 18:33:05 +08; 2min 26s ago
       Docs: https://www.postgresql.org/docs/17/static/
    Process: 5911 ExecStartPre=/usr/pgsql-17/bin/postgresql-17-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 5916 (postgres)
      Tasks: 7 (limit: 15700)
     Memory: 21.3M
        CPU: 177ms
     CGroup: /system.slice/postgresql-17.service
             ├─5916 /usr/pgsql-17/bin/postgres -D /pgData/pgsql17/data/
             ├─5917 "postgres: logger "
             ├─5918 "postgres: checkpointer "
             ├─5919 "postgres: background writer "
             ├─5921 "postgres: walwriter "
             ├─5922 "postgres: autovacuum launcher "
             └─5923 "postgres: logical replication launcher "

Oct 07 18:33:05 lxicbpgdsgv01.rajasekhar.com systemd[1]: Starting PostgreSQL 17 database server...
Oct 07 18:33:05 lxicbpgdsgv01.rajasekhar.com postgres[5916]: 2025-10-07 18:33:05.392 +08 [5916] LOG:  redirecting log output to logging collector process
Oct 07 18:33:05 lxicbpgdsgv01.rajasekhar.com postgres[5916]: 2025-10-07 18:33:05.392 +08 [5916] HINT:  Future log output will appear in directory "log".
Oct 07 18:33:05 lxicbpgdsgv01.rajasekhar.com systemd[1]: Started PostgreSQL 17 database server.
[root@lxicbpgdsgv01 ~]#

Currently, there is no active archive process running in the background.

2. Ensure Archive Directory Exists

[root@lxicbpgdsgv01 ~]# mkdir -p /pgArch/pgsql17/arch/
[root@lxicbpgdsgv01 ~]# chown postgres:postgres /pgArch/pgsql17/arch/
[root@lxicbpgdsgv01 ~]# chmod 700 /pgArch/pgsql17/arch/

3. Edit postgresql.conf

[postgres@lxicbpgdsgv01 ~]$ vi /pgData/pgsql17/data/postgresql.conf

Update or add the following lines:

archive_mode = on
archive_command = 'cp %p /pgArch/pgsql17/arch/%f'

Explanation:

  • %p = Full path of WAL file
  • %f = WAL file name
  • cp %p /pgArch/pgsql17/arch/%f = Command to copy the WAL file to archive directory

4. Restart PostgreSQL

[root@lxicbpgdsgv01 ~]# systemctl status postgresql-17
● postgresql-17.service - PostgreSQL 17 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-17.service; enabled; preset: disabled)
     Active: active (running) since Tue 2025-10-07 23:48:29 +08; 18s ago
       Docs: https://www.postgresql.org/docs/17/static/
    Process: 7868 ExecStartPre=/usr/pgsql-17/bin/postgresql-17-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 7873 (postgres)
      Tasks: 8 (limit: 15700)
     Memory: 19.0M
        CPU: 96ms
     CGroup: /system.slice/postgresql-17.service
             ├─7873 /usr/pgsql-17/bin/postgres -D /pgData/pgsql17/data/
             ├─7874 "postgres: logger "
             ├─7875 "postgres: checkpointer "
             ├─7876 "postgres: background writer "
             ├─7878 "postgres: walwriter "
             ├─7879 "postgres: autovacuum launcher "
             ├─7880 "postgres: archiver "  <------
             └─7881 "postgres: logical replication launcher "

Oct 07 23:48:29 lxicbpgdsgv01.rajasekhar.com systemd[1]: Starting PostgreSQL 17 database server...
Oct 07 23:48:29 lxicbpgdsgv01.rajasekhar.com postgres[7873]: 2025-10-07 23:48:29.503 +08 [7873] LOG:  redirecting log output to logging collector process
Oct 07 23:48:29 lxicbpgdsgv01.rajasekhar.com postgres[7873]: 2025-10-07 23:48:29.503 +08 [7873] HINT:  Future log output will appear in directory "log".
Oct 07 23:48:29 lxicbpgdsgv01.rajasekhar.com systemd[1]: Started PostgreSQL 17 database server.
[root@lxicbpgdsgv01 ~]#

Make sure the archiver process is running.

5. Verify the Configuration

[postgres@lxicbpgdsgv01 ~]$ psql -c "SHOW archive_mode;"
 archive_mode 
--------------
 on <-----------
(1 row)

[postgres@lxicbpgdsgv01 ~]$ psql -c "SHOW archive_command;"
        archive_command         
-------------------------------
 cp %p /pgArch/pgsql17/arch/%f  <-----------------
(1 row)

6. Test Archiving Works

[postgres@lxicbpgdsgv01 ~]$ psql -c "SELECT pg_switch_wal();"

Check archive folder for new WAL files:

[postgres@lxicbpgdsgv01 ~]$ ls -lrth /pgArch/pgsql17/arch/
total 16M
-rw-------. 1 postgres postgres 16M Oct  7 23:50 000000010000000000000001

[postgres@lxicbpgdsgv01 ~]$ psql -c "SELECT pg_switch_wal();"
[postgres@lxicbpgdsgv01 ~]$ ls -lrth /pgArch/pgsql17/arch/
total 32M
-rw-------. 1 postgres postgres 16M Oct  7 23:50 000000010000000000000001
-rw-------. 1 postgres postgres 16M Oct  7 23:51 000000010000000000000002

 Archiving is working successfully.

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

Change Data Directory

PostgreSQL 17 – Change Data Directory


0. Overview
1. Stop PostgreSQL Service
2. Create the New Directory
3. Copy Existing Data to New Location
4. Move existing data directory
5. Update PostgreSQL Configuration to Use New Data Directory
6. Reload systemd and start PostgreSQL
7. Edit postgres .bash_profile
8. Verify New Data Directory is in Use
9. Remove Old Data Directory (Optional – A week after)


0. Overview

To change the PostgreSQL 17 data directory from its default location

From: /var/lib/pgsql/17/data To: /pgData/pgsql17/data

 

1. Stop PostgreSQL Service

[postgres@lxicbpgdsgv01 ~]$ psql -c "SHOW data_directory;"
     data_directory
------------------------
 /var/lib/pgsql/17/data <---- existing data directory
(1 row)

[postgres@lxicbpgdsgv01 ~]$

[root@lxicbpgdsgv01 ~]# systemctl stop postgresql-17
[root@lxicbpgdsgv01 ~]# 
[root@lxicbpgdsgv01 ~]# ps -ef | grep postgres
root        5759    4079  0 18:09 pts/1    00:00:00 grep --color=auto postgres
[root@lxicbpgdsgv01 ~]#

2. Create the New Directory

[root@lxicbpgdsgv01 ~]# mkdir -p /pgData/pgsql17/data
[root@lxicbpgdsgv01 ~]# chown postgres:postgres /pgData/pgsql17/data
[root@lxicbpgdsgv01 ~]# chmod 700 /pgData/pgsql17/data
[root@lxicbpgdsgv01 ~]#

3. Copy Existing Data to New Location

[postgres@lxicbpgdsgv01 ~]$ nohup rsync -av --progress /var/lib/pgsql/17/data/ /pgData/pgsql17/data/ > rsync_pgdata.log 2>&1 &
[1] 5863
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ tail -f rsync_pgdata.log
pg_wal/000000010000000000000002
     16,777,216 100%   17.68MB/s    0:00:00 (xfr#1621, to-chk=3/1652)
pg_wal/archive_status/
pg_wal/summaries/
pg_xact/
pg_xact/0000
          8,192 100%    8.84kB/s    0:00:00 (xfr#1622, to-chk=0/1652)

sent 73,827,441 bytes  received 31,005 bytes  49,238,964.00 bytes/sec
total size is 73,717,583  speedup is 1.00
^C[1]+  Done                    nohup rsync -av --progress /var/lib/pgsql/17/data/ /pgData/pgsql17/data/ > rsync_pgdata.log 2>&1

[postgres@lxicbpgdsgv01 ~]$

4. Move existing data directory

[postgres@lxicbpgdsgv01 ~]$ mv /var/lib/pgsql/17/data /var/lib/pgsql/17/data_bkp_10072025
[postgres@lxicbpgdsgv01 ~]$

5. Update PostgreSQL Configuration to Use New Data Directory

[postgres@lxicbpgdsgv01 ~]$ cat /usr/lib/systemd/system/postgresql-17.service | grep -i "Environment=PGDATA"
Environment=PGDATA=/var/lib/pgsql/17/data/  <-----
[postgres@lxicbpgdsgv01 ~]$

[root@lxicbpgdsgv01 ~]# ls -ltr /usr/lib/systemd/system/postgresql-17.service
-rw-r--r--. 1 root root 1788 Aug 13 17:39 /usr/lib/systemd/system/postgresql-17.service
[root@lxicbpgdsgv01 ~]#

[root@lxicbpgdsgv01 ~]# sed -i 's|^Environment=PGDATA=.*|Environment=PGDATA=/pgData/pgsql17/data/|' /usr/lib/systemd/system/postgresql-17.service
[root@lxicbpgdsgv01 ~]#
[root@lxicbpgdsgv01 ~]# cat /usr/lib/systemd/system/postgresql-17.service | grep -i "Environment=PGDATA"
Environment=PGDATA=/pgData/pgsql17/data/ <------
[root@lxicbpgdsgv01 ~]#

6. Reload systemd and start PostgreSQL

[root@lxicbpgdsgv01 ~]# systemctl daemon-reload
[root@lxicbpgdsgv01 ~]#

[root@lxicbpgdsgv01 ~]# systemctl start postgresql-17
[root@lxicbpgdsgv01 ~]#

[root@lxicbpgdsgv01 ~]# systemctl cat postgresql-17 | grep -i Environment=PGDATA
Environment=PGDATA=/pgData/pgsql17/data/ <-----
[root@lxicbpgdsgv01 ~]#

[root@lxicbpgdsgv01 ~]# systemctl status postgresql-17
● postgresql-17.service - PostgreSQL 17 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-17.service; enabled; preset: disabled)
     Active: active (running) since Tue 2025-10-07 18:33:05 +08; 2min 26s ago
       Docs: https://www.postgresql.org/docs/17/static/
    Process: 5911 ExecStartPre=/usr/pgsql-17/bin/postgresql-17-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 5916 (postgres)
      Tasks: 7 (limit: 15700)
     Memory: 21.3M
        CPU: 177ms
     CGroup: /system.slice/postgresql-17.service
            ─5916 /usr/pgsql-17/bin/postgres -D /pgData/pgsql17/data/
             ├─5917 "postgres: logger "
             ├─5918 "postgres: checkpointer "
             ├─5919 "postgres: background writer "
             ├─5921 "postgres: walwriter "
             ├─5922 "postgres: autovacuum launcher "
             └─5923 "postgres: logical replication launcher "

Oct 07 18:33:05 lxicbpgdsgv01.rajasekhar.com systemd[1]: Starting PostgreSQL 17 database server...
Oct 07 18:33:05 lxicbpgdsgv01.rajasekhar.com postgres[5916]: 2025-10-07 18:33:05.392 +08 [5916] LOG:  redirecting log output to logging collector process
Oct 07 18:33:05 lxicbpgdsgv01.rajasekhar.com postgres[5916]: 2025-10-07 18:33:05.392 +08 [5916] HINT:  Future log output will appear in directory "log".
Oct 07 18:33:05 lxicbpgdsgv01.rajasekhar.com systemd[1]: Started PostgreSQL 17 database server.

7. Edit postgres .bash_profile

[postgres@lxicbpgdsgv01 ~]$ cat .bash_profile | grep -i PGDATA=
PGDATA=/var/lib/pgsql/17/data
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ sed -i 's|^PGDATA=.*|PGDATA=/pgData/pgsql17/data|' ~/.bash_profile
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ cat .bash_profile | grep -i PGDATA=
PGDATA=/pgData/pgsql17/data <-----
[postgres@lxicbpgdsgv01 ~]$ . .bash_profile <-- reload the profile
[postgres@lxicbpgdsgv01 ~]$

8. Verify New Data Directory is in Use

[postgres@lxicbpgdsgv01 ~]$ psql -c "SHOW data_directory;"
    data_directory
----------------------
 /pgData/pgsql17/data  <---- new data directory
(1 row)

[postgres@lxicbpgdsgv01 ~]$

9. Remove Old Data Directory (Optional – A week after)

[postgres@lxicbpgdsgv01 ~]$ ls -ld /var/lib/pgsql/17/data_bkp_10072025
drwx------. 20 postgres postgres 4096 Oct  7 18:20 /var/lib/pgsql/17/data_bkp_10072025
[postgres@lxicbpgdsgv01 ~]$ rm -rf /var/lib/pgsql/17/data_bkp_10072025
[postgres@lxicbpgdsgv01 ~]$

 

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

PostgreSQL Backup and Restore Using pg_dumpall

PostgreSQL Backup and Restore Using pg_dumpall and psql

Table of Contents


0. Introduction

Backup:

1. Backup All Databases
2. Backup Users/Roles Definition
3. Backup Tablespaces Definition
4. Backup Schema Only (No Data)
5. Backup Data Only (No Schema)
6. Backup Data as INSERT Commands
7. Backup Global Objects Only (No Databases)

Restore:

8. Restore on Same Host

9. Restore to Another Host (Different Tablespace Paths)


Click to expand pg_dumpall –help
[postgres@lxtrdpgdsgv01 ~]$ pg_dumpall --help
pg_dumpall extracts a PostgreSQL database cluster into an SQL script file.

Usage:
  pg_dumpall [OPTION]...

General options:
  -f, --file=FILENAME          output file name
  -v, --verbose                verbose mode
  -V, --version                output version information, then exit
  --lock-wait-timeout=TIMEOUT  fail after waiting TIMEOUT for a table lock
  -?, --help                   show this help, then exit

Options controlling the output content:
  -a, --data-only              dump only the data, not the schema
  -c, --clean                  clean (drop) databases before recreating
  -E, --encoding=ENCODING      dump the data in encoding ENCODING
  -g, --globals-only           dump only global objects, no databases
  -O, --no-owner               skip restoration of object ownership
  -r, --roles-only             dump only roles, no databases or tablespaces
  -s, --schema-only            dump only the schema, no data
  -S, --superuser=NAME         superuser user name to use in the dump
  -t, --tablespaces-only       dump only tablespaces, no databases or roles
  -x, --no-privileges          do not dump privileges (grant/revoke)
  --binary-upgrade             for use by upgrade utilities only
  --column-inserts             dump data as INSERT commands with column names
  --disable-dollar-quoting     disable dollar quoting, use SQL standard quoting
  --disable-triggers           disable triggers during data-only restore
  --exclude-database=PATTERN   exclude databases whose name matches PATTERN
  --extra-float-digits=NUM     override default setting for extra_float_digits
  --if-exists                  use IF EXISTS when dropping objects
  --inserts                    dump data as INSERT commands, rather than COPY
  --load-via-partition-root    load partitions via the root table
  --no-comments                do not dump comments
  --no-publications            do not dump publications
  --no-role-passwords          do not dump passwords for roles
  --no-security-labels         do not dump security label assignments
  --no-subscriptions           do not dump subscriptions
  --no-sync                    do not wait for changes to be written safely to disk
  --no-table-access-method     do not dump table access methods
  --no-tablespaces             do not dump tablespace assignments
  --no-toast-compression       do not dump TOAST compression methods
  --no-unlogged-table-data     do not dump unlogged table data
  --on-conflict-do-nothing     add ON CONFLICT DO NOTHING to INSERT commands
  --quote-all-identifiers      quote all identifiers, even if not key words
  --restrict-key=RESTRICT_KEY  use provided string as psql \restrict key
  --rows-per-insert=NROWS      number of rows per INSERT; implies --inserts
  --use-set-session-authorization
                               use SET SESSION AUTHORIZATION commands instead of
                               ALTER OWNER commands to set ownership

Connection options:
  -d, --dbname=CONNSTR     connect using connection string
  -h, --host=HOSTNAME      database server host or socket directory
  -l, --database=DBNAME    alternative default database
  -p, --port=PORT          database server port number
  -U, --username=NAME      connect as specified database user
  -w, --no-password        never prompt for password
  -W, --password           force password prompt (should happen automatically)
  --role=ROLENAME          do SET ROLE before dump

If -f/--file is not used, then the SQL script will be written to the standard
output.

Report bugs to <pgsql-bugs@lists.postgresql.org>.
PostgreSQL home page: <https://www.postgresql.org/>
[postgres@lxtrdpgdsgv01 ~]$

 

0. Introduction

Note: pg_dumpall does not support custom format backups.

The pg_dumpall utility is used to back up an entire PostgreSQL environment, including:

* Roles and users
* Tablespaces
* All databases (schemas and data)

It is especially useful for:

* Full cluster migrations
* Disaster recovery
* Environment replication across dev, QA, and prod

When restoring to a different host, you'll need to:

* Update tablespace paths (using tools like sed)
* Pre-create required tablespace directories

This ensures compatibility and successful restoration across different environments.

Backup


1. Backup ALL databases

[postgres@lxtrdpgdsgv01 ~]$ nohup pg_dumpall -U postgres -v -f /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql > /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.log 2>&1 &
[1] 5610
[postgres@lxtrdpgdsgv01 ~]$ 
[postgres@lxtrdpgdsgv01 ~]$ cat /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.log | grep -i /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql
pg_dumpall: running ""/usr/pgsql-15/bin/pg_dump"  -v -f /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql  -Fa 'user=postgres dbname=template1'"
pg_dumpall: running ""/usr/pgsql-15/bin/pg_dump"  -v -f /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql --create -Fa 'user=postgres dbname=edpua'"
pg_dumpall: running ""/usr/pgsql-15/bin/pg_dump"  -v -f /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql --create -Fa 'user=postgres dbname=gebua'"
pg_dumpall: running ""/usr/pgsql-15/bin/pg_dump"  -v -f /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql --create -Fa 'user=postgres dbname=orcl'"
pg_dumpall: running ""/usr/pgsql-15/bin/pg_dump"  -v -f /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql  -Fa 'user=postgres dbname=postgres'"
[postgres@lxtrdpgdsgv01 ~]$

[postgres@lxtrdpgdsgv01 ~]$ psql
psql (15.14)
Type "help" for help.

postgres=# \c orcl
You are now connected to database "orcl" as user "postgres".
orcl=# SELECT
orcl-#     schemaname || '.' || relname AS table_name,
orcl-#     pg_size_pretty(pg_total_relation_size(relid)) AS total_size,
orcl-#     pg_size_pretty(pg_relation_size(relid)) AS table_size,
orcl-#     pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) AS index_size
orcl-# FROM
orcl-#     pg_catalog.pg_statio_user_tables
orcl-# ORDER BY
orcl-#     pg_total_relation_size(relid) DESC;
    table_name    | total_size | table_size | index_size
------------------+------------+------------+------------
 trd.metrics_high | 799 MB     | 498 MB     | 301 MB
 trd.metrics_mid  | 638 MB     | 398 MB     | 240 MB
 trd.employees    | 493 MB     | 322 MB     | 172 MB
 trd.sales_2023   | 399 MB     | 249 MB     | 150 MB
 trd.sales_2024   | 399 MB     | 249 MB     | 150 MB
 trd.sales_2022   | 399 MB     | 249 MB     | 150 MB
 trd.sales_2021   | 398 MB     | 248 MB     | 150 MB
 trd.metrics_low  | 159 MB     | 99 MB      | 60 MB
 trd.test_data    | 71 MB      | 50 MB      | 21 MB
 trd.emp_summary  | 24 kB      | 8192 bytes | 16 kB
 trd.metrics_rest | 8192 bytes | 0 bytes    | 8192 bytes
(11 rows)

orcl=#


2. Backup users/roles definition

[postgres@lxtrdpgdsgv01 ~]$ nohup pg_dumpall -U postgres --roles-only -v -f /pgBackup/pgsql15/backup/roles.sql > /pgBackup/pgsql15/backup/roles.log 2>&1 &
[1] 5205
[postgres@lxtrdpgdsgv01 ~]$


3. Backup tablespaces definition

[postgres@lxtrdpgdsgv01 ~]$ nohup pg_dumpall -U postgres --tablespaces-only -v -f /pgBackup/pgsql15/backup/tablespaces.sql > /pgBackup/pgsql15/backup/tablespaces.log 2>&1 &
[1] 5183
[postgres@lxtrdpgdsgv01 ~]$


4. Backup dump only the schema, no data

[postgres@lxtrdpgdsgv01 ~]$ nohup pg_dumpall -U postgres --schema-only -v -f /pgBackup/pgsql15/backup/schemas.sql > /pgBackup/pgsql15/backup/schemas.log 2>&1 &
[1] 4890
[postgres@lxtrdpgdsgv01 ~]$ 


5. Backup dump only the data, not the schema

[postgres@lxtrdpgdsgv01 ~]$ nohup pg_dumpall -U postgres --data-only -v -f /pgBackup/pgsql15/backup/dataonly.sql > /pgBackup/pgsql15/backup/dataonly.log 2>&1 &
[1] 5233
[postgres@lxtrdpgdsgv01 ~]$ 


6. Backup dump data as INSERT commands, rather than COPY

[postgres@lxtrdpgdsgv01 ~]$ nohup pg_dumpall -U postgres --inserts -v -f /pgBackup/pgsql15/backup/inserts.sql > /pgBackup/pgsql15/backup/inserts.log 2>&1 &
[1] 5274
[postgres@lxtrdpgdsgv01 ~]$


7. Backup dump only global objects, no databases

[postgres@lxtrdpgdsgv01 ~]$ nohup pg_dumpall -U postgres --globals-only -v -f /pgBackup/pgsql15/backup/globals.sql > /pgBackup/pgsql15/backup/globals.log 2>&1 &
[1] 5331
[postgres@lxtrdpgdsgv01 ~]$

Restore


8. Restore on same host


A. Drop Existing Databases (Optional)

 

[postgres@lxtrdpgdsgv01 ~]$ psql
psql (15.14)
Type "help" for help.

postgres=# \l
                                                 List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    | ICU Locale | Locale Provider |   Access privileges
-----------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
 edpua     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 gebua     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 orcl      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/postgres          +
           |          |          |             |             |            |                 | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | postgres=CTc/postgres+
           |          |          |             |             |            |                 | =c/postgres
(6 rows)

postgres=# drop database edpua;
DROP DATABASE
postgres=# drop database gebua;
DROP DATABASE
postgres=# drop database orcl;
DROP DATABASE
postgres=# \l
                                                 List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    | ICU Locale | Locale Provider |   Access privileges
-----------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/postgres          +
           |          |          |             |             |            |                 | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | postgres=CTc/postgres+
           |          |          |             |             |            |                 | =c/postgres
(3 rows)

postgres=#

postgres=# \db
             List of tablespaces
    Name    |  Owner   |      Location
------------+----------+---------------------
 edpua_ix   | postgres | /pgIx/pgsql15/edpua
 edpua_tb   | postgres | /pgTb/pgsql15/edpua
 gebua_ix   | postgres | /pgIx/pgsql15/gebua
 gebua_tb   | postgres | /pgTb/pgsql15/gebua
 orcl_ix    | postgres | /pgIx/pgsql15/orcl
 orcl_tb    | postgres | /pgTb/pgsql15/orcl
 pg_default | postgres |
 pg_global  | postgres |
(8 rows)

postgres=#


B. Restore Full Backup

[postgres@lxtrdpgdsgv01 ~]$ nohup psql -U postgres -X -f /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql -d postgres > /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025_restore.log
[1] 4132
[postgres@lxtrdpgdsgv01 ~]$ 

-- OR --

nohup psql -U postgres -f /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql > /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025_restore.log 2>&1 &

-- Log: backup_all_databases_10OCT2025_restore.log


C. Verification

[postgres@lxtrdpgdsgv01 ~]$ psql
psql (15.14)
Type "help" for help.

postgres=# \l
                                                 List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    | ICU Locale | Locale Provider |   Access privileges
-----------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
 edpua     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 gebua     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 orcl      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/postgres          +
           |          |          |             |             |            |                 | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | postgres=CTc/postgres+
           |          |          |             |             |            |                 | =c/postgres
(6 rows)

postgres=#


9. Restore to Another Host (Different Tablespace Paths)

A. Copy Backup File

[postgres@lxtrdpgdsgv01 backup]$ scp backup_all_databases_10OCT2025.sql 192.168.2.31:/pgBackup/pgsql15/backup/
postgres@192.168.2.31's password:
backup_all_databases_10OCT2025.sql                 100% 3556MB  51.5MB/s   01:09
[postgres@lxtrdpgdsgv01 backup]$ 

[postgres@pg17 backup]$ ls -ltr backup_all_databases_10OCT2025.sql
-rw-r--r--. 1 postgres postgres 3729147646 Oct  6 06:17 backup_all_databases_10OCT2025.sql
[postgres@pg17 backup]$


B. Extract Tablespace/Database Info

[postgres@lxtrdpgdsgv01 backup]$ grep -i "CREATE TABLESPACE" /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql
CREATE TABLESPACE orcl_tb OWNER postgres LOCATION '/pgTb/pgsql15/orcl';
CREATE TABLESPACE orcl_ix OWNER postgres LOCATION '/pgIx/pgsql15/orcl';
CREATE TABLESPACE gebua_tb OWNER postgres LOCATION '/pgTb/pgsql15/gebua';
CREATE TABLESPACE gebua_ix OWNER postgres LOCATION '/pgIx/pgsql15/gebua';
CREATE TABLESPACE edpua_tb OWNER postgres LOCATION '/pgTb/pgsql15/edpua';
CREATE TABLESPACE edpua_ix OWNER postgres LOCATION '/pgIx/pgsql15/edpua';
[postgres@lxtrdpgdsgv01 backup]$
[postgres@lxtrdpgdsgv01 backup]$ grep -i "CREATE DATABASE" /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql
CREATE DATABASE edpua WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'en_US.UTF-8' TABLESPACE = edpua_tb;
CREATE DATABASE gebua WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'en_US.UTF-8' TABLESPACE = gebua_tb;
CREATE DATABASE orcl WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'en_US.UTF-8' TABLESPACE = orcl_tb;
[postgres@lxtrdpgdsgv01 backup]$


C. Create Tablespace Directories on Target

[postgres@pg17 ~]$ psql
psql (15.13)
Type "help" for help.

postgres=# \l
                                                 List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    | ICU Locale | Locale Provider |   Access privileges
-----------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/postgres          +
           |          |          |             |             |            |                 | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | postgres=CTc/postgres+
           |          |          |             |             |            |                 | =c/postgres
(3 rows)

postgres=#
postgres=# \db
       List of tablespaces
    Name    |  Owner   | Location
------------+----------+----------
 pg_default | postgres |
 pg_global  | postgres |
(2 rows)

postgres=#


# Create Directory 

[postgres@pg17 ~]$ mkdir -p /pgData/pgsql15/orcl_tb
[postgres@pg17 ~]$ mkdir -p /pgData/pgsql15/orcl_ix
[postgres@pg17 ~]$ mkdir -p /pgData/pgsql15/gebua_tb
[postgres@pg17 ~]$ mkdir -p /pgData/pgsql15/gebua_ix
[postgres@pg17 ~]$ mkdir -p /pgData/pgsql15/edpua_tb
[postgres@pg17 ~]$ mkdir -p /pgData/pgsql15/edpua_ix


D. Create Tablespaces in PostgreSQL

postgres=# CREATE TABLESPACE orcl_tb OWNER postgres LOCATION  '/pgData/pgsql15/orcl_tb';
CREATE TABLESPACE
postgres=# CREATE TABLESPACE orcl_ix OWNER postgres LOCATION  '/pgData/pgsql15/orcl_ix';
CREATE TABLESPACE
postgres=# CREATE TABLESPACE gebua_tb OWNER postgres LOCATION '/pgData/pgsql15/gebua_tb';
CREATE TABLESPACE
postgres=# CREATE TABLESPACE gebua_ix OWNER postgres LOCATION '/pgData/pgsql15/gebua_ix';
CREATE TABLESPACE
postgres=# CREATE TABLESPACE edpua_tb OWNER postgres LOCATION '/pgData/pgsql15/edpua_tb';
CREATE TABLESPACE
postgres=# CREATE TABLESPACE edpua_ix OWNER postgres LOCATION '/pgData/pgsql15/edpua_ix';
CREATE TABLESPACE
postgres=#


-- OR --- 
 You can modify the tablespace paths directly in the backup file; however, this approach is not recommended for large backup files due to  reliability concerns.

cd /pgBackup/pgsql15/backup/
# Replace ORCL paths
sed -i 's|/pgTb/pgsql15/orcl|/pgData/pgsql15/orcl_tb|g' backup_all_databases_10OCT2025.sql
sed -i 's|/pgIx/pgsql15/orcl|/pgData/pgsql15/orcl_ix|g' backup_all_databases_10OCT2025.sql

# Replace GEBUA paths
sed -i 's|/pgTb/pgsql15/gebua|/pgData/pgsql15/gebua_tb|g' backup_all_databases_10OCT2025.sql
sed -i 's|/pgIx/pgsql15/gebua|/pgData/pgsql15/gebua_ix|g' backup_all_databases_10OCT2025.sql

# Replace EDPUA paths
sed -i 's|/pgTb/pgsql15/edpua|/pgData/pgsql15/edpua_tb|g' backup_all_databases_10OCT2025.sql
sed -i 's|/pgIx/pgsql15/edpua|/pgData/pgsql15/edpua_ix|g' backup_all_databases_10OCT2025.sql


[postgres@pg17 ~]$ psql
psql (15.13)
Type "help" for help.

postgres=# \db
               List of tablespaces
    Name    |  Owner   |         Location
------------+----------+--------------------------
 edpua_ix   | postgres | /pgData/pgsql15/edpua_ix
 edpua_tb   | postgres | /pgData/pgsql15/edpua_tb
 gebua_ix   | postgres | /pgData/pgsql15/gebua_ix
 gebua_tb   | postgres | /pgData/pgsql15/gebua_tb
 orcl_ix    | postgres | /pgData/pgsql15/orcl_ix
 orcl_tb    | postgres | /pgData/pgsql15/orcl_tb
 pg_default | postgres |
 pg_global  | postgres |
(8 rows)

postgres=# 


E. Optional: Backup on Target Host

[postgres@pg17 ~]$ nohup pg_dumpall -U postgres -v -f /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025_pg17.sql > /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025_pg17.log 2>&1 &
[1] 4246
[postgres@pg17 ~]$


F. Restore on Target Host

[postgres@pg17 ~]$ nohup psql -U postgres -X -f /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql -d postgres > /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025_restore_pg17.log 2>&1 &
[1] 5213
[postgres@pg17 ~]$ 

-- OR --

nohup psql -U postgres -f /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025.sql > /pgBackup/pgsql15/backup/backup_all_databases_10OCT2025_restore_pg17.log 2>&1 &

-- Log: backup_all_databases_10OCT2025_restore_pg17.log


G. Final Verification

[postgres@pg17 ~]$ psql
psql (15.13)
Type "help" for help.

postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | ICU Locale | Locale Provider | Access privileges
-----------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
 edpua | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc |
gebua | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc |
orcl | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc | =c/postgres +
| | | | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc | postgres=CTc/postgres+
| | | | | | | =c/postgres
(6 rows)

postgres=#

[postgres@pg17 ~]$ psql
psql (15.13)
Type "help" for help.

postgres=# \c orcl
You are now connected to database "orcl" as user "postgres".
orcl=# SELECT
orcl-# schemaname || '.' || relname AS table_name,
orcl-# pg_size_pretty(pg_total_relation_size(relid)) AS total_size,
orcl-# pg_size_pretty(pg_relation_size(relid)) AS table_size,
orcl-# pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) AS index_size
orcl-# FROM
orcl-# pg_catalog.pg_statio_user_tables
orcl-# ORDER BY
orcl-# pg_total_relation_size(relid) DESC;
 table_name | total_size | table_size | index_size
------------------+------------+------------+------------
trd.metrics_high | 799 MB | 498 MB | 301 MB
trd.metrics_mid | 638 MB | 398 MB | 240 MB
trd.employees | 493 MB | 322 MB | 172 MB
trd.sales_2023 | 399 MB | 249 MB | 150 MB
trd.sales_2024 | 399 MB | 249 MB | 150 MB
trd.sales_2022 | 399 MB | 249 MB | 150 MB
trd.sales_2021 | 398 MB | 248 MB | 150 MB
trd.metrics_low | 159 MB | 99 MB | 60 MB
trd.test_data | 71 MB | 50 MB | 21 MB
trd.emp_summary | 24 kB | 8192 bytes | 16 kB
trd.metrics_rest | 8192 bytes | 0 bytes | 8192 bytes
(11 rows)

orcl=#

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

pg_dump & pg_restore

PostgreSQL pg_dump and pg_restore Guide

Table of Contents
___________________________________________________________________________________________________

Backup:

0. pg_dump / pg_restore –help
1. Backup Output Formats
2. Full Database Backup

3. Schema Level Backup
4. Table Level Backup
5. Object Level Backup (PostgreSQL v17 Feature)

Restore:

6. Pre-requisites for Restore
7. Full Database Restore
8. Schema Level Restore

9. Table Level Restore

___________________________________________________________________________________________________

0. pg_dump/pg_restore –help

Click to expand pg_dump –help
[postgres@pg17 ~]$ pg_dump --help
pg_dump dumps a database as a text file or to other formats.

Usage:
  pg_dump [OPTION]... [DBNAME]

General options:
  -f, --file=FILENAME          output file or directory name
  -F, --format=c|d|t|p         output file format (custom, directory, tar,
                               plain text (default))
  -j, --jobs=NUM               use this many parallel jobs to dump
  -v, --verbose                verbose mode
  -V, --version                output version information, then exit
  -Z, --compress=0-9           compression level for compressed formats
  --lock-wait-timeout=TIMEOUT  fail after waiting TIMEOUT for a table lock
  --no-sync                    do not wait for changes to be written safely to disk
  -?, --help                   show this help, then exit

Options controlling the output content:
  -a, --data-only              dump only the data, not the schema
  -b, --blobs                  include large objects in dump
  -B, --no-blobs               exclude large objects in dump
  -c, --clean                  clean (drop) database objects before recreating
  -C, --create                 include commands to create database in dump
  -e, --extension=PATTERN      dump the specified extension(s) only
  -E, --encoding=ENCODING      dump the data in encoding ENCODING
  -n, --schema=PATTERN         dump the specified schema(s) only
  -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)
  -O, --no-owner               skip restoration of object ownership in
                               plain-text format
  -s, --schema-only            dump only the schema, no data
  -S, --superuser=NAME         superuser user name to use in plain-text format
  -t, --table=PATTERN          dump the specified table(s) only
  -T, --exclude-table=PATTERN  do NOT dump the specified table(s)
  -x, --no-privileges          do not dump privileges (grant/revoke)
  --binary-upgrade             for use by upgrade utilities only
  --column-inserts             dump data as INSERT commands with column names
  --disable-dollar-quoting     disable dollar quoting, use SQL standard quoting
  --disable-triggers           disable triggers during data-only restore
  --enable-row-security        enable row security (dump only content user has
                               access to)
  --exclude-table-data=PATTERN do NOT dump data for the specified table(s)
  --extra-float-digits=NUM     override default setting for extra_float_digits
  --if-exists                  use IF EXISTS when dropping objects
  --include-foreign-data=PATTERN
                               include data of foreign tables on foreign
                               servers matching PATTERN
  --inserts                    dump data as INSERT commands, rather than COPY
  --load-via-partition-root    load partitions via the root table
  --no-comments                do not dump comments
  --no-publications            do not dump publications
  --no-security-labels         do not dump security label assignments
  --no-subscriptions           do not dump subscriptions
  --no-table-access-method     do not dump table access methods
  --no-tablespaces             do not dump tablespace assignments
  --no-toast-compression       do not dump TOAST compression methods
  --no-unlogged-table-data     do not dump unlogged table data
  --on-conflict-do-nothing     add ON CONFLICT DO NOTHING to INSERT commands
  --quote-all-identifiers      quote all identifiers, even if not key words
  --rows-per-insert=NROWS      number of rows per INSERT; implies --inserts
  --section=SECTION            dump named section (pre-data, data, or post-data)
  --serializable-deferrable    wait until the dump can run without anomalies
  --snapshot=SNAPSHOT          use given snapshot for the dump
  --strict-names               require table and/or schema include patterns to
                               match at least one entity each
  --use-set-session-authorization
                               use SET SESSION AUTHORIZATION commands instead of
                               ALTER OWNER commands to set ownership

Connection options:
  -d, --dbname=DBNAME      database to dump
  -h, --host=HOSTNAME      database server host or socket directory
  -p, --port=PORT          database server port number
  -U, --username=NAME      connect as specified database user
  -w, --no-password        never prompt for password
  -W, --password           force password prompt (should happen automatically)
  --role=ROLENAME          do SET ROLE before dump

If no database name is supplied, then the PGDATABASE environment
variable value is used.

Report bugs to <pgsql-bugs@lists.postgresql.org>.
PostgreSQL home page: <https://www.postgresql.org/>
[postgres@pg17 ~]$
Click to expand pg_restore –help
[postgres@pg17 ~]$ pg_restore --help
pg_restore restores a PostgreSQL database from an archive created by pg_dump.

Usage:
  pg_restore [OPTION]... [FILE]

General options:
  -d, --dbname=NAME        connect to database name
  -f, --file=FILENAME      output file name (- for stdout)
  -F, --format=c|d|t       backup file format (should be automatic)
  -l, --list               print summarized TOC of the archive
  -v, --verbose            verbose mode
  -V, --version            output version information, then exit
  -?, --help               show this help, then exit

Options controlling the restore:
  -a, --data-only              restore only the data, no schema
  -c, --clean                  clean (drop) database objects before recreating
  -C, --create                 create the target database
  -e, --exit-on-error          exit on error, default is to continue
  -I, --index=NAME             restore named index
  -j, --jobs=NUM               use this many parallel jobs to restore
  -L, --use-list=FILENAME      use table of contents from this file for
                               selecting/ordering output
  -n, --schema=NAME            restore only objects in this schema
  -N, --exclude-schema=NAME    do not restore objects in this schema
  -O, --no-owner               skip restoration of object ownership
  -P, --function=NAME(args)    restore named function
  -s, --schema-only            restore only the schema, no data
  -S, --superuser=NAME         superuser user name to use for disabling triggers
  -t, --table=NAME             restore named relation (table, view, etc.)
  -T, --trigger=NAME           restore named trigger
  -x, --no-privileges          skip restoration of access privileges (grant/revoke)
  -1, --single-transaction     restore as a single transaction
  --disable-triggers           disable triggers during data-only restore
  --enable-row-security        enable row security
  --if-exists                  use IF EXISTS when dropping objects
  --no-comments                do not restore comments
  --no-data-for-failed-tables  do not restore data of tables that could not be
                               created
  --no-publications            do not restore publications
  --no-security-labels         do not restore security labels
  --no-subscriptions           do not restore subscriptions
  --no-table-access-method     do not restore table access methods
  --no-tablespaces             do not restore tablespace assignments
  --section=SECTION            restore named section (pre-data, data, or post-data)
  --strict-names               require table and/or schema include patterns to
                               match at least one entity each
  --use-set-session-authorization
                               use SET SESSION AUTHORIZATION commands instead of
                               ALTER OWNER commands to set ownership

Connection options:
  -h, --host=HOSTNAME      database server host or socket directory
  -p, --port=PORT          database server port number
  -U, --username=NAME      connect as specified database user
  -w, --no-password        never prompt for password
  -W, --password           force password prompt (should happen automatically)
  --role=ROLENAME          do SET ROLE before restore

The options -I, -n, -N, -P, -t, -T, and --section can be combined and specified
multiple times to select multiple objects.

If no input file name is supplied, then standard input is used.

Report bugs to <pgsql-bugs@lists.postgresql.org>.
PostgreSQL home page: <https://www.postgresql.org/>
[postgres@pg17 ~]$

1. Backup Output Formats

A. Plain Text Format
# Using -Fp explicitly:
pg_dump -U postgres -d your_db_name -Fp -f /path/to/your_db.sql

# Shell redirect
pg_dump -U postgres -d your_db_name > /path/to/your_db.sql

B. Tar Format
pg_dump -U postgres -d your_db_name -Ft -f /path/to/your_db.tar

C. Directory Format and Parallel Backup
-- Parallel backup is only supported with -Fd
-- pg_dump will create the directory if it doesn't exist.

# Without parallelism
pg_dump -U postgres -d your_db_name -Fd -f /path/to/backup_dir/

# With parallelism
pg_dump -U postgres -d your_db_name -Fd -j8 -f /path/to/backup_dir/

D. Custom Format (Compressed binary format by default)
pg_dump -U postgres -d your_db_name -Fc -f /path/to/your_db.dump


2. Full Database Backup


A. Plain Text Format

[postgres@pg17 ~]$ nohup pg_dump -U postgres -d blpua -v > /pgBackup/pgsql15/backup/blpua/database_blpua_full.sql 2> /pgBackup/pgsql15/backup/blpua/log/database_blpua_full.log &

-- OR --

[postgres@pg17 ~]$ nohup pg_dump -U postgres -d blpua -v -Fp -f /pgBackup/pgsql15/backup/blpua/database_blpua_full1.sql > /pgBackup/pgsql15/backup/blpua/log/database_blpua_full1.log 2>&1 &

-- OR -- 

[postgres@pg17 ~]$ pg_dump -U postgres -d blpua | split -b 1G - /pgBackup/pgsql15/backup/blpua/database_blpua_split.dmp
[postgres@pg17 ~]$
[postgres@pg17 ~]$ ls -lrth /pgBackup/pgsql15/backup/blpua/database_blpua_s*
-rw-r--r--. 1 postgres postgres 1.0G Sep 30 11:03 /pgBackup/pgsql15/backup/blpua/database_blpua_split.dmpaa
-rw-r--r--. 1 postgres postgres 650M Sep 30 11:03 /pgBackup/pgsql15/backup/blpua/database_blpua_split.dmpab
[postgres@pg17 ~]$

-- OR --

[postgres@pg17 ~]$ nohup sh -c "pg_dump -U postgres -d blpua -v | gzip > /pgBackup/pgsql15/backup/blpua/database_blpua.gz" > /pgBackup/pgsql15/backup/blpua/log/database_blpua.log 2>&1 &

-- OR --

[postgres@pg17 ~]$ nohup pg_dump -U postgres -d blpua -v > /pgBackup/pgsql15/backup/blpua/database_blpua.sql 2> /pgBackup/pgsql15/backup/blpua/log/database_blpua.log & gzip /pgBackup/pgsql15/backup/blpua/database_blpua.sql


B. Tar Format

[postgres@pg17 ~]$ nohup pg_dump -U postgres -d blpua -v -Ft -f /pgBackup/pgsql15/backup/blpua/database_blpua.tar > /pgBackup/pgsql15/backup/blpua/log/blpua_tar_dump.log 2>&1 &


C. Directory Format

[postgres@pg17 ~]$ nohup pg_dump -U postgres -d blpua -v -Fd -j4 -f /pgBackup/pgsql15/backup/blpua_dir > /pgBackup/pgsql15/backup/blpua/log/blpua_dump.log 2>&1 &


D. Custome Format

[postgres@pg17 ~]$ nohup pg_dump -U postgres -d blpua -Fc -v -f /pgBackup/pgsql15/backup/blpua/database_blpua_$(date +%Y_%m_%d).dmp > /pgBackup/pgsql15/backup/blpua/log/database_blpua_$(date +%Y_%m_%d).log 2>&1 &
[postgres@pg17 ~]$ 
[postgres@pg17 ~]$ ls -lrth /pgBackup/pgsql15/backup/blpua/database_blpua*.dmp
-rw-r--r--. 1 postgres postgres 402M Sep 29 04:58 /pgBackup/pgsql15/backup/blpua/database_blpua_2025_09_29.dmp

[postgres@pg17 ~]$ ls -lrth /pgBackup/pgsql15/backup/blpua/log/database_blpua*.log
-rw-r--r--. 1 postgres postgres 2.5K Sep 29 04:58 /pgBackup/pgsql15/backup/blpua/log/database_blpua_2025_09_29.log
[postgres@pg17 ~]$


3. Schema Level Backup

[postgres@pg17 ~]$ nohup pg_dump -U postgres -d blpua -n blp -Fc -v -f /pgBackup/pgsql15/backup/blpua/schema_blp_blpua_$(date +%Y_%m_%d).dmp > /pgBackup/pgsql15/backup/blpua/log/schema_blp_blpua_$(date +%Y_%m_%d).log 2>&1 &
[1] 5472
[postgres@pg17 ~]$

[postgres@pg17 ~]$ jobs -l
[1]+  5472 Running                 nohup pg_dump -U postgres -d blpua -n blp -Fc -v -f /pgBackup/pgsql15/backup/blpua/schema_blp_blpua_$(date +%Y_%m_%d).dmp > /pgBackup/pgsql15/backup/blpua/log/schema_blp_blpua_$(date +%Y_%m_%d).log 2>&1 &
[postgres@pg17 ~]$

[postgres@pg17 ~]$ jobs -l
[1]+  5472 Done                    nohup pg_dump -U postgres -d blpua -n blp -Fc -v -f /pgBackup/pgsql15/backup/blpua/schema_blp_blpua_$(date +%Y_%m_%d).dmp > /pgBackup/pgsql15/backup/blpua/log/schema_blp_blpua_$(date +%Y_%m_%d).log 2>&1
[postgres@pg17 ~]$


[postgres@pg17 ~]$ ls -lrth /pgBackup/pgsql15/backup/blpua/schema_blp_blpua*
-rw-r--r--. 1 postgres postgres 402M Sep 30 02:09 /pgBackup/pgsql15/backup/blpua/schema_blp_blpua_2025_09_30.dmp
[postgres@pg17 ~]$ ls -lrth /pgBackup/pgsql15/backup/blpua/log/schema_blp_blpua*
-rw-r--r--. 1 postgres postgres 2.5K Sep 30 02:09 /pgBackup/pgsql15/backup/blpua/log/schema_blp_blpua_2025_09_30.log
[postgres@pg17 ~]$


4. Table Level Backup

[postgres@pg17 ~]$ nohup pg_dump -U postgres -d blpua -t blp.employees -Fc -v -f /pgBackup/pgsql15/backup/blpua/table_blp_employees_$(date +%Y_%m_%d).dmp > /pgBackup/pgsql15/backup/blpua/log/table_blp_employees_$(date +%Y_%m_%d).log 2>&1 &
[1] 5652
[postgres@pg17 ~]$ 

[postgres@pg17 ~]$ ls -lrth /pgBackup/pgsql15/backup/blpua/table_blp_employees_*
-rw-r--r--. 1 postgres postgres 62M Sep 30 02:22 /pgBackup/pgsql15/backup/blpua/table_blp_employees_2025_09_30.dmp
[postgres@pg17 ~]$ ls -lrth /pgBackup/pgsql15/backup/blpua/log/table_blp_employees_*
-rw-r--r--. 1 postgres postgres 2.0K Sep 30 02:22 /pgBackup/pgsql15/backup/blpua/log/table_blp_employees_2025_09_30.log
[postgres@pg17 ~]$


5. Object Level Backup (PostgreSQL v17 Feature)

++ filter is only for pg_dump, not pg_restore

[postgres@lxicbpgdsgv01 ~]$ cat include_tables.par
include table demo.table_1
include table demo.table_2
include table demo.table_3
[postgres@lxicbpgdsgv01 ~]$


[postgres@lxicbpgdsgv01 ~]$ pg_dump -d testdb_source --filter=include_tables.par > include_tables.sql

[postgres@lxicbpgdsgv01 ~]$ ls -lrth include_tables.sql
-rw-r--r--. 1 postgres postgres 4.5K Sep 30 22:19 include_tables.sql
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ cat include_tables.sql | grep -i "CREATE TABLE"
CREATE TABLE demo.table_1 (
CREATE TABLE demo.table_2 (
CREATE TABLE demo.table_3 (
[postgres@lxicbpgdsgv01 ~]$


[postgres@lxicbpgdsgv01 ~]$ cat exclude_tables.par
exclude table demo.table_1
exclude table demo.table_2
exclude table demo.table_3
[postgres@lxicbpgdsgv01 ~]$

[postgres@lxicbpgdsgv01 ~]$ pg_dump -d testdb_source --filter=exclude_tables.par > exclude_tables.sql
[postgres@lxicbpgdsgv01 ~]$ ls -ltr exclude_tables.sql
-rw-r--r--. 1 postgres postgres 10931 Sep 30 22:23 exclude_tables.sql
[postgres@lxicbpgdsgv01 ~]$
[postgres@lxicbpgdsgv01 ~]$ cat exclude_tables.sql | grep -i "CREATE TABLE"
CREATE TABLE demo.table_10 (
CREATE TABLE demo.table_4 (
CREATE TABLE demo.table_5 (
CREATE TABLE demo.table_6 (
CREATE TABLE demo.table_7 (
CREATE TABLE demo.table_8 (
CREATE TABLE demo.table_9 (
[postgres@lxicbpgdsgv01 ~]$


6. Pre-requisites for restore

postgres=# CREATE TABLESPACE TEST_TB LOCATION '/pgTb/pgsql15/test';
CREATE TABLESPACE
postgres=# CREATE TABLESPACE TEST_IX LOCATION '/pgIx/pgsql15/test';
CREATE TABLESPACE
postgres=#
postgres=# CREATE DATABASE TEST TABLESPACE TEST_TB;
CREATE DATABASE
postgres=#

[postgres@pg17 blpua]$ scp *.dmp postgres@192.168.2.32:/pgBackup/pgsql15/backup/test
postgres@192.168.2.32's password:
database_blpua_2025_09_29.dmp                           100%  402MB  39.9MB/s   00:10
schema_blp_blpua_2025_09_30.dmp                         100%  402MB  43.8MB/s   00:09
table_blp_employees_2025_09_30.dmp                      100%   61MB  47.0MB/s   00:01
[postgres@pg17 blpua]$


7. Full Database Restore

++ The source database uses two custom tablespaces: blpua_tbs01 and blpua_ixtbs01.
++ On the target system, I have two different tablespaces: test_tb and test_ix.
++ Unlike Oracle, PostgreSQL does not provide a direct equivalent of REMAP_TABLESPACE.
++ Therefore, to simplify the restore and ensure all objects are placed into the default tablespace (test_tb).
++ Using --no-owner --no-tablespaces in pg_restore — even if not specified, data still gets written to the default database tablespace. These options just help avoid errors in the log.
++ This ensures that all objects are restored to the default tablespace of the target database, regardless of their original tablespace assignments.
++ Later, we can move all indexes to the desired target tablespace using the ALTER INDEX ... SET TABLESPACE command.
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# ALTER INDEX blp.idx_employee_name SET TABLESPACE test_ix;  <--  This command physically relocates the index to the test_ix tablespace.
ALTER INDEX
test=#


[postgres@lxtrdpgdsgv01 ~]$ nohup pg_restore -U postgres -d test --no-owner --no-tablespaces -v /pgBackup/pgsql15/backup/test/database_blpua_2025_09_29.dmp > /pgBackup/pgsql15/backup/test/log/restore_blpua_test_$(date +%Y_%m_%d).log 2>&1 &
[1] 5300
[postgres@lxtrdpgdsgv01 ~]$

[postgres@lxtrdpgdsgv01 ~]$ cat /pgBackup/pgsql15/backup/test/log/restore_blpua_test_2025_09_30.log
nohup: ignoring input
pg_restore: connecting to database for restore
pg_restore: creating SCHEMA "blp"
pg_restore: creating TYPE "blp.address"
pg_restore: creating TYPE "blp.employment_status"
pg_restore: creating DOMAIN "blp.positive_integer"
pg_restore: creating FUNCTION "blp.get_salary(integer)"
pg_restore: creating FUNCTION "blp.log_update()"
pg_restore: creating PROCEDURE "blp.raise_salary(integer, numeric)"
pg_restore: creating SEQUENCE "blp.emp_id_seq"
pg_restore: creating TABLE "blp.employees"
pg_restore: creating MATERIALIZED VIEW "blp.emp_summary"
pg_restore: creating SEQUENCE "blp.employees_id_seq"
pg_restore: creating SEQUENCE OWNED BY "blp.employees_id_seq"
pg_restore: creating VIEW "blp.high_paid_employees"
pg_restore: creating TABLE "blp.metrics"
pg_restore: creating TABLE "blp.metrics_high"
pg_restore: creating SEQUENCE "blp.metrics_id_seq"
pg_restore: creating TABLE "blp.metrics_low"
pg_restore: creating TABLE "blp.metrics_mid"
pg_restore: creating TABLE "blp.metrics_rest"
pg_restore: creating TABLE "blp.sales"
pg_restore: creating TABLE "blp.sales_2021"
pg_restore: creating TABLE "blp.sales_2022"
pg_restore: creating TABLE "blp.sales_2023"
pg_restore: creating TABLE "blp.sales_2024"
pg_restore: creating SEQUENCE "blp.sales_id_seq"
pg_restore: creating TABLE "blp.test_data"
pg_restore: creating SEQUENCE "blp.test_data_id_seq"
pg_restore: creating SEQUENCE OWNED BY "blp.test_data_id_seq"
pg_restore: creating TABLE ATTACH "blp.metrics_high"
pg_restore: creating TABLE ATTACH "blp.metrics_low"
pg_restore: creating TABLE ATTACH "blp.metrics_mid"
pg_restore: creating TABLE ATTACH "blp.metrics_rest"
pg_restore: creating TABLE ATTACH "blp.sales_2021"
pg_restore: creating TABLE ATTACH "blp.sales_2022"
pg_restore: creating TABLE ATTACH "blp.sales_2023"
pg_restore: creating TABLE ATTACH "blp.sales_2024"
pg_restore: creating DEFAULT "blp.employees id"
pg_restore: creating DEFAULT "blp.test_data id"
pg_restore: processing data for table "blp.employees"
pg_restore: processing data for table "blp.metrics_high"
pg_restore: processing data for table "blp.metrics_low"
pg_restore: processing data for table "blp.metrics_mid"
pg_restore: processing data for table "blp.metrics_rest"
pg_restore: processing data for table "blp.sales_2021"
pg_restore: processing data for table "blp.sales_2022"
pg_restore: processing data for table "blp.sales_2023"
pg_restore: processing data for table "blp.sales_2024"
pg_restore: processing data for table "blp.test_data"
pg_restore: executing SEQUENCE SET emp_id_seq
pg_restore: executing SEQUENCE SET employees_id_seq
pg_restore: executing SEQUENCE SET metrics_id_seq
pg_restore: executing SEQUENCE SET sales_id_seq
pg_restore: executing SEQUENCE SET test_data_id_seq
pg_restore: creating CONSTRAINT "blp.employees employees_pkey"
pg_restore: creating CONSTRAINT "blp.metrics metrics_pkey"
pg_restore: creating CONSTRAINT "blp.metrics_high metrics_high_pkey"
pg_restore: creating CONSTRAINT "blp.metrics_low metrics_low_pkey"
pg_restore: creating CONSTRAINT "blp.metrics_mid metrics_mid_pkey"
pg_restore: creating CONSTRAINT "blp.metrics_rest metrics_rest_pkey"
pg_restore: creating CONSTRAINT "blp.sales sales_pkey"
pg_restore: creating CONSTRAINT "blp.sales_2021 sales_2021_pkey"
pg_restore: creating CONSTRAINT "blp.sales_2022 sales_2022_pkey"
pg_restore: creating CONSTRAINT "blp.sales_2023 sales_2023_pkey"
pg_restore: creating CONSTRAINT "blp.sales_2024 sales_2024_pkey"
pg_restore: creating CONSTRAINT "blp.test_data test_data_pkey"
pg_restore: creating INDEX "blp.idx_employee_name"
pg_restore: creating INDEX ATTACH "blp.metrics_high_pkey"
pg_restore: creating INDEX ATTACH "blp.metrics_low_pkey"
pg_restore: creating INDEX ATTACH "blp.metrics_mid_pkey"
pg_restore: creating INDEX ATTACH "blp.metrics_rest_pkey"
pg_restore: creating INDEX ATTACH "blp.sales_2021_pkey"
pg_restore: creating INDEX ATTACH "blp.sales_2022_pkey"
pg_restore: creating INDEX ATTACH "blp.sales_2023_pkey"
pg_restore: creating INDEX ATTACH "blp.sales_2024_pkey"
pg_restore: creating TRIGGER "blp.employees employee_update_trigger"
pg_restore: creating MATERIALIZED VIEW DATA "blp.emp_summary"
[postgres@lxtrdpgdsgv01 ~]$


8. Schema Level Restore

++ pg_restore does not support schema remapping like Oracle’s REMAP_SCHEMA.
++ I want to restore schema blp --> trd. 
++ Option A: Restore Dump as it is, Then Rename <--- Best for simplicity
++ Option B: Split Dump into Schema + Data, Modify Both <--- This is more complex, but possible if you must use schema remapping.
++ This is schema dump file : /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp
++ Using --no-owner --no-tablespaces in pg_restore — even if not specified, data still gets written to the default database tablespace. These options just help avoid errors in the log.


A. To Restore schema from own schema’s backup

postgres=# CREATE TABLESPACE ORCL_TB LOCATION '/pgTb/pgsql15/orcl';
CREATE TABLESPACE
postgres=# CREATE TABLESPACE ORCL_IX LOCATION '/pgIx/pgsql15/orcl';
CREATE TABLESPACE
postgres=#
postgres=# CREATE DATABASE ORCL TABLESPACE ORCL_TB;
CREATE DATABASE
postgres=#

-- With NO parallelism


[postgres@lxtrdpgdsgv01 ~]$ nohup pg_restore -U postgres -d orcl --no-owner --no-tablespaces -v /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp > /pgBackup/pgsql15/backup/test/log/restore_blpua_test_$(date +%Y_%m_%d).log 2>&1 &
[1] 7344
[postgres@lxtrdpgdsgv01 ~]$

postgres=# \c orcl
You are now connected to database "orcl" as user "postgres".
orcl=# ALTER SCHEMA blp RENAME TO trd;
ALTER SCHEMA
orcl=# \dn
      List of schemas
  Name  |       Owner
--------+-------------------
 public | pg_database_owner
 trd    | postgres
(2 rows)

orcl=#


[postgres@lxtrdpgdsgv01 ~]$ cat /pgBackup/pgsql15/backup/test/log/restore_blpua_test_2025_09_30.log
nohup: ignoring input
pg_restore: connecting to database for restore
pg_restore: creating SCHEMA "blp"
pg_restore: creating TYPE "blp.address"
pg_restore: creating TYPE "blp.employment_status"
pg_restore: creating DOMAIN "blp.positive_integer"
pg_restore: creating FUNCTION "blp.get_salary(integer)"
pg_restore: creating FUNCTION "blp.log_update()"
pg_restore: creating PROCEDURE "blp.raise_salary(integer, numeric)"
pg_restore: creating SEQUENCE "blp.emp_id_seq"
pg_restore: creating TABLE "blp.employees"
pg_restore: creating MATERIALIZED VIEW "blp.emp_summary"
pg_restore: creating SEQUENCE "blp.employees_id_seq"
pg_restore: creating SEQUENCE OWNED BY "blp.employees_id_seq"
pg_restore: creating VIEW "blp.high_paid_employees"
pg_restore: creating TABLE "blp.metrics"
pg_restore: creating TABLE "blp.metrics_high"
pg_restore: creating SEQUENCE "blp.metrics_id_seq"
pg_restore: creating TABLE "blp.metrics_low"
pg_restore: creating TABLE "blp.metrics_mid"
pg_restore: creating TABLE "blp.metrics_rest"
pg_restore: creating TABLE "blp.sales"
pg_restore: creating TABLE "blp.sales_2021"
pg_restore: creating TABLE "blp.sales_2022"
pg_restore: creating TABLE "blp.sales_2023"
pg_restore: creating TABLE "blp.sales_2024"
pg_restore: creating SEQUENCE "blp.sales_id_seq"
pg_restore: creating TABLE "blp.test_data"
pg_restore: creating SEQUENCE "blp.test_data_id_seq"
pg_restore: creating SEQUENCE OWNED BY "blp.test_data_id_seq"
pg_restore: creating TABLE ATTACH "blp.metrics_high"
pg_restore: creating TABLE ATTACH "blp.metrics_low"
pg_restore: creating TABLE ATTACH "blp.metrics_mid"
pg_restore: creating TABLE ATTACH "blp.metrics_rest"
pg_restore: creating TABLE ATTACH "blp.sales_2021"
pg_restore: creating TABLE ATTACH "blp.sales_2022"
pg_restore: creating TABLE ATTACH "blp.sales_2023"
pg_restore: creating TABLE ATTACH "blp.sales_2024"
pg_restore: creating DEFAULT "blp.employees id"
pg_restore: creating DEFAULT "blp.test_data id"
pg_restore: processing data for table "blp.employees"
pg_restore: processing data for table "blp.metrics_high"
pg_restore: processing data for table "blp.metrics_low"
pg_restore: processing data for table "blp.metrics_mid"
pg_restore: processing data for table "blp.metrics_rest"
pg_restore: processing data for table "blp.sales_2021"
pg_restore: processing data for table "blp.sales_2022"
pg_restore: processing data for table "blp.sales_2023"
pg_restore: processing data for table "blp.sales_2024"
pg_restore: processing data for table "blp.test_data"
pg_restore: executing SEQUENCE SET emp_id_seq
pg_restore: executing SEQUENCE SET employees_id_seq
pg_restore: executing SEQUENCE SET metrics_id_seq
pg_restore: executing SEQUENCE SET sales_id_seq
pg_restore: executing SEQUENCE SET test_data_id_seq
pg_restore: creating CONSTRAINT "blp.employees employees_pkey"
pg_restore: creating CONSTRAINT "blp.metrics metrics_pkey"
pg_restore: creating CONSTRAINT "blp.metrics_high metrics_high_pkey"
pg_restore: creating CONSTRAINT "blp.metrics_low metrics_low_pkey"
pg_restore: creating CONSTRAINT "blp.metrics_mid metrics_mid_pkey"
pg_restore: creating CONSTRAINT "blp.metrics_rest metrics_rest_pkey"
pg_restore: creating CONSTRAINT "blp.sales sales_pkey"
pg_restore: creating CONSTRAINT "blp.sales_2021 sales_2021_pkey"
pg_restore: creating CONSTRAINT "blp.sales_2022 sales_2022_pkey"
pg_restore: creating CONSTRAINT "blp.sales_2023 sales_2023_pkey"
pg_restore: creating CONSTRAINT "blp.sales_2024 sales_2024_pkey"
pg_restore: creating CONSTRAINT "blp.test_data test_data_pkey"
pg_restore: creating INDEX "blp.idx_employee_name"
pg_restore: creating INDEX ATTACH "blp.metrics_high_pkey"
pg_restore: creating INDEX ATTACH "blp.metrics_low_pkey"
pg_restore: creating INDEX ATTACH "blp.metrics_mid_pkey"
pg_restore: creating INDEX ATTACH "blp.metrics_rest_pkey"
pg_restore: creating INDEX ATTACH "blp.sales_2021_pkey"
pg_restore: creating INDEX ATTACH "blp.sales_2022_pkey"
pg_restore: creating INDEX ATTACH "blp.sales_2023_pkey"
pg_restore: creating INDEX ATTACH "blp.sales_2024_pkey"
pg_restore: creating TRIGGER "blp.employees employee_update_trigger"
pg_restore: creating MATERIALIZED VIEW DATA "blp.emp_summary"
[postgres@lxtrdpgdsgv01 ~]$


--- OR ---

-- With parallelism 4

nohup pg_restore -U postgres -d orcl -j4 --no-owner --no-tablespaces -v /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp > /pgBackup/pgsql15/backup/test/log/restore_blpua_test_$(date +%Y_%m_%d).log1 2>&1 &

[postgres@lxtrdpgdsgv01 ~]$ ps -ef | grep pg_restore
postgres    7089    5102  0 05:49 pts/0    00:00:00 pg_restore -U postgres -d orcl -j4 --no-owner --no-tablespaces -v /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp
postgres    7091    7089  2 05:49 pts/0    00:00:00 pg_restore -U postgres -d orcl -j4 --no-owner --no-tablespaces -v /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp
postgres    7092    7089  3 05:49 pts/0    00:00:00 pg_restore -U postgres -d orcl -j4 --no-owner --no-tablespaces -v /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp
postgres    7093    7089  2 05:49 pts/0    00:00:00 pg_restore -U postgres -d orcl -j4 --no-owner --no-tablespaces -v /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp
postgres    7094    7089  2 05:49 pts/0    00:00:00 pg_restore -U postgres -d orcl -j4 --no-owner --no-tablespaces -v /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp
postgres    7126    5736  0 05:49 pts/1    00:00:00 grep --color=auto pg_restore
[postgres@lxtrdpgdsgv01 ~]$


B. To Restore only a specific schema from Full Database Backup

Step 1: Create schema 

gebua=# CREATE SCHEMA IF NOT EXISTS blp;

Step 2: Restore Objects and Data

nohup pg_restore -U postgres -d gebua -n blp --no-owner --no-tablespaces -v /pgBackup/pgsql15/backup/test/database_blpua_2025_09_29.dmp > /pgBackup/pgsql15/backup/test/log/restore_blpua_test_$(date +%Y_%m_%d).log_full 2>&1 &


9. Table Level Restore


A. Restore Table from own table’s backup

[postgres@lxtrdpgdsgv01 ~]$ pg_restore -l /pgBackup/pgsql15/backup/test/table_blp_employees_2025_09_30.dmp
;
; Archive created at 2025-09-30 02:22:21 EDT
;     dbname: blpua
;     TOC Entries: 13
;     Compression: -1
;     Dump Version: 1.14-0
;     Format: CUSTOM
;     Integer: 4 bytes
;     Offset: 8 bytes
;     Dumped from database version: 15.13
;     Dumped by pg_dump version: 15.13
;
;
; Selected TOC Entries:
;
229; 1259 92805 TABLE blp employees postgres
228; 1259 92804 SEQUENCE blp employees_id_seq postgres
4338; 0 0 SEQUENCE OWNED BY blp employees_id_seq postgres
4181; 2604 92808 DEFAULT blp employees id postgres
4331; 0 92805 TABLE DATA blp employees postgres
4339; 0 0 SEQUENCE SET blp employees_id_seq postgres
4183; 2606 92812 CONSTRAINT blp employees employees_pkey postgres
4184; 1259 92824 INDEX blp idx_employee_name postgres
4185; 2620 92829 TRIGGER blp employees employee_update_trigger postgres
[postgres@lxtrdpgdsgv01 ~]$


Step 1: Create schema 

postgres=# \c edpua
You are now connected to database "edpua" as user "postgres".
edpua=# CREATE SCHEMA IF NOT EXISTS blp;
CREATE SCHEMA
edpua=#


Step 2: Restore Objects and Data

[postgres@lxtrdpgdsgv01 ~]$ pg_restore -U postgres -d edpua --no-tablespaces -v /pgBackup/pgsql15/backup/test/table_blp_employees_2025_09_30.dmp
pg_restore: connecting to database for restore
pg_restore: creating TABLE "blp.employees"
pg_restore: creating SEQUENCE "blp.employees_id_seq"
pg_restore: creating SEQUENCE OWNED BY "blp.employees_id_seq"
pg_restore: creating DEFAULT "blp.employees id"
pg_restore: processing data for table "blp.employees"
pg_restore: executing SEQUENCE SET employees_id_seq
pg_restore: creating CONSTRAINT "blp.employees employees_pkey"
pg_restore: creating INDEX "blp.idx_employee_name"
pg_restore: creating TRIGGER "blp.employees employee_update_trigger"
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 4185; 2620 92829 TRIGGER employees employee_update_trigger postgres
pg_restore: error: could not execute query: ERROR:  function blp.log_update() does not exist
Command was: CREATE TRIGGER employee_update_trigger AFTER UPDATE ON blp.employees FOR EACH ROW EXECUTE FUNCTION blp.log_update();


pg_restore: warning: errors ignored on restore: 1
[postgres@lxtrdpgdsgv01 ~]$

++ PostgreSQL does not have a --ignore-errors flag, The above erros ignorable.


B. Restore Single Table data-only from Schema backup

edpua=# TRUNCATE TABLE blp.employees;
TRUNCATE TABLE
edpua=#

[postgres@lxtrdpgdsgv01 ~]$ pg_restore -U postgres -d edpua --data-only -t employees -v /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp
pg_restore: connecting to database for restore
pg_restore: processing data for table "blp.employees"
[postgres@lxtrdpgdsgv01 ~]$

edpua=# select count(*) from blp.employees;
 5000000  <-----

edpua=#


C. Restore Single Table from Schema backup

Step 1: Create schema 

edpua=# CREATE SCHEMA blp;

Step 2: Restore Objects and Data

[postgres@lxtrdpgdsgv01 ~]$ pg_restore -U postgres -d edpua --clean -t employees -v /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp
pg_restore: connecting to database for restore
pg_restore: dropping TABLE employees
pg_restore: creating TABLE "blp.employees"
pg_restore: processing data for table "blp.employees"
[postgres@lxtrdpgdsgv01 ~]$
[postgres@lxtrdpgdsgv01 ~]$ psql
psql (15.14)
Type "help" for help.

postgres=# \c edpua
You are now connected to database "edpua" as user "postgres".
edpua=# select count(*) from blp.employees;
  count
---------
 5000000 <----
(1 row)

edpua=#


D. Restore Single Table from Schema backup (add both -n and -t)

[postgres@lxtrdpgdsgv01 ~]$ pg_restore -U postgres -d edpua --clean -n blp -t employees -v /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp
pg_restore: connecting to database for restore
pg_restore: dropping TABLE employees
pg_restore: creating TABLE "blp.employees"
pg_restore: processing data for table "blp.employees"
[postgres@lxtrdpgdsgv01 ~]$
[postgres@lxtrdpgdsgv01 ~]$ psql
psql (15.14)
Type "help" for help.

postgres=# \c edpua
You are now connected to database "edpua" as user "postgres".
edpua=# select count(*) from blp.employees;
  count
---------
 5000000 <-----
(1 row)

edpua=#


E. Restoring Using a Plain SQL File (COPY-based)

Step 1: Extracted table data from custom-format dump

[postgres@lxtrdpgdsgv01 ~]$ pg_restore -U postgres -n blp -t employees -f /pgBackup/pgsql15/backup/test/blp_employees.sql /pgBackup/pgsql15/backup/test/schema_blp_blpua_2025_09_30.dmp
[postgres@lxtrdpgdsgv01 ~]$
[postgres@lxtrdpgdsgv01 ~]$ ls -lrth /pgBackup/pgsql15/backup/test/blp_employees.sql
-rw-r--r--. 1 postgres postgres 210M Sep 30 09:17 /pgBackup/pgsql15/backup/test/blp_employees.sql
[postgres@lxtrdpgdsgv01 ~]$

[postgres@lxtrdpgdsgv01 ~]$ head -50 /pgBackup/pgsql15/backup/test/blp_employees.sql
--
-- PostgreSQL database dump
--

\restrict TthhVsS8JvVxrplYNApzHUalZpygXUqFg2pIvbSH8GTkbJ6WBNyW0JLnuuvkPdt

-- Dumped from database version 15.13
-- Dumped by pg_dump version 15.13

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: employees; Type: TABLE; Schema: blp; Owner: postgres
--

CREATE TABLE blp.employees (
    id integer NOT NULL,
    name text,
    salary numeric(10,2),
    hired_on date
);


ALTER TABLE blp.employees OWNER TO postgres;

--
-- Data for Name: employees; Type: TABLE DATA; Schema: blp; Owner: postgres
--

COPY blp.employees (id, name, salary, hired_on) FROM stdin;
1       Employee_1      70969.47        2005-06-13
2       Employee_2      94341.15        2006-12-09
3       Employee_3      101657.57       2012-07-05
4       Employee_4      54701.92        2010-01-05
5       Employee_5      104229.43       2001-06-28
6       Employee_6      95842.57        2010-10-06
7       Employee_7      50618.08        2015-06-02
[postgres@lxtrdpgdsgv01 ~]$

Step 2: Restore using psql command

postgres=# \c edpua
You are now connected to database "edpua" as user "postgres".
edpua=#
edpua=# drop table blp.employees;
DROP TABLE
edpua=# exit
[postgres@lxtrdpgdsgv01 ~]$


psql -U postgres -d edpua < /pgBackup/pgsql15/backup/test/blp_employees.sql

[postgres@lxtrdpgdsgv01 ~]$ psql -U postgres -d edpua < /pgBackup/pgsql15/backup/test/blp_employees.sql
SET
SET
SET
SET
SET
 set_config
------------

(1 row)

SET
SET
SET
SET
SET
SET
CREATE TABLE
ALTER TABLE
COPY 5000000
[postgres@lxtrdpgdsgv01 ~]$

[postgres@lxtrdpgdsgv01 ~]$ psql
psql (15.14)
Type "help" for help.

postgres=# \c edpua
You are now connected to database "edpua" as user "postgres".
edpua=# SELECT COUNT(*) FROM blp.employees;
  count
---------
 5000000 <-----
(1 row)

edpua=#

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

Install PostgreSQL Using Source Code

How to Install PostgreSQL 13 Using Source Code on Linux 7

Table of Contents
___________________________________________________________________________________________________

1. Install required packages
2. Download the source code tar file
3. Extract tar file
4. configure –help
5. Create postgres user and required directories
6. Configure postgreSQL
7. Build postgreSQL using make command
8. Install postgreSQL using make install command
9. Build contrib module using make command (optional)
10. Install contrib module using make install command (optional)
11. Validation
12. Change binary owner to postgres
13. Initialize postgreSQL data directory using postgres user
14. Validate the postgreSQL data directory
15. Start postgreSQL database as postgres user
16. Setting the postgres User Environment Variables
17. Create postgreSQL DB and test the installation

___________________________________________________________________________________________________


1. Install required packages

[root@pcs1 ~]# dhclient
[root@pcs1 ~]# yum install readline-devel
Loaded plugins: langpacks, ulninfo
ol7_UEKR4                                                                                                                                                                                                             | 3.0 kB  00:00:00
ol7_latest                                                                                                                                                                                                            | 3.6 kB  00:00:00
(1/4): ol7_UEKR4/x86_64/updateinfo                                                                                                                                                                                    | 107 kB  00:00:00
(2/4): ol7_latest/x86_64/updateinfo                                                                                                                                                                                   | 3.4 MB  00:00:03
(3/4): ol7_UEKR4/x86_64/primary_db                                                                                                                                                                                    |  18 MB  00:00:11
(4/4): ol7_latest/x86_64/primary_db                                                                                                                                                                                   |  37 MB  00:00:12
Resolving Dependencies
--> Running transaction check
---> Package readline-devel.x86_64 0:6.2-11.el7 will be installed
--> Processing Dependency: readline = 6.2-11.el7 for package: readline-devel-6.2-11.el7.x86_64
--> Processing Dependency: ncurses-devel for package: readline-devel-6.2-11.el7.x86_64
--> Running transaction check
---> Package ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 will be installed
---> Package readline.x86_64 0:6.2-10.el7 will be updated
---> Package readline.x86_64 0:6.2-11.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================================================================
 Package                                                   Arch                                              Version                                                             Repository                                             Size
=============================================================================================================================================================================================================================================
Installing:
 readline-devel                                            x86_64                                            6.2-11.el7                                                          ol7_latest                                            138 k
Installing for dependencies:
 ncurses-devel                                             x86_64                                            5.9-14.20130511.el7_4                                               ol7_latest                                            712 k
Updating for dependencies:
 readline                                                  x86_64                                            6.2-11.el7                                                          ol7_latest                                            193 k

Transaction Summary
=============================================================================================================================================================================================================================================
Install  1 Package  (+1 Dependent package)
Upgrade             ( 1 Dependent package)

Total download size: 1.0 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for ol7_latest
(1/3): readline-6.2-11.el7.x86_64.rpm                                                                                                                                                                                 | 193 kB  00:00:00
(2/3): readline-devel-6.2-11.el7.x86_64.rpm                                                                                                                                                                           | 138 kB  00:00:00
(3/3): ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm                                                                                                                                                                 | 712 kB  00:00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                        1.0 MB/s | 1.0 MB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : ncurses-devel-5.9-14.20130511.el7_4.x86_64                                                                                                                                                                                1/4
  Updating   : readline-6.2-11.el7.x86_64                                                                                                                                                                                                2/4
  Installing : readline-devel-6.2-11.el7.x86_64                                                                                                                                                                                          3/4
  Cleanup    : readline-6.2-10.el7.x86_64                                                                                                                                                                                                4/4
  Verifying  : readline-devel-6.2-11.el7.x86_64                                                                                                                                                                                          1/4
  Verifying  : readline-6.2-11.el7.x86_64                                                                                                                                                                                                2/4
  Verifying  : ncurses-devel-5.9-14.20130511.el7_4.x86_64                                                                                                                                                                                3/4
  Verifying  : readline-6.2-10.el7.x86_64                                                                                                                                                                                                4/4

Installed:
  readline-devel.x86_64 0:6.2-11.el7

Dependency Installed:
  ncurses-devel.x86_64 0:5.9-14.20130511.el7_4

Dependency Updated:
  readline.x86_64 0:6.2-11.el7

Complete!
[root@pcs1 ~]#

[root@pcs1 ~]# yum install -y zlib-devel
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package zlib-devel.x86_64 0:1.2.7-19.el7_9 will be installed
--> Processing Dependency: zlib = 1.2.7-19.el7_9 for package: zlib-devel-1.2.7-19.el7_9.x86_64
--> Running transaction check
---> Package zlib.x86_64 0:1.2.7-17.el7 will be updated
---> Package zlib.x86_64 0:1.2.7-19.el7_9 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================================================================
 Package                                                  Arch                                                 Version                                                        Repository                                                Size
=============================================================================================================================================================================================================================================
Installing:
 zlib-devel                                               x86_64                                               1.2.7-19.el7_9                                                 ol7_latest                                                50 k
Updating for dependencies:
 zlib                                                     x86_64                                               1.2.7-19.el7_9                                                 ol7_latest                                                89 k

Transaction Summary
=============================================================================================================================================================================================================================================
Install  1 Package
Upgrade             ( 1 Dependent package)

Total download size: 139 k
Downloading packages:
No Presto metadata available for ol7_latest
(1/2): zlib-devel-1.2.7-19.el7_9.x86_64.rpm                                                                                                                                                                           |  50 kB  00:00:00
(2/2): zlib-1.2.7-19.el7_9.x86_64.rpm                                                                                                                                                                                 |  89 kB  00:00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                        159 kB/s | 139 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : zlib-1.2.7-19.el7_9.x86_64                                                                                                                                                                                                1/3
  Installing : zlib-devel-1.2.7-19.el7_9.x86_64                                                                                                                                                                                          2/3
  Cleanup    : zlib-1.2.7-17.el7.x86_64                                                                                                                                                                                                  3/3
  Verifying  : zlib-devel-1.2.7-19.el7_9.x86_64                                                                                                                                                                                          1/3
  Verifying  : zlib-1.2.7-19.el7_9.x86_64                                                                                                                                                                                                2/3
  Verifying  : zlib-1.2.7-17.el7.x86_64                                                                                                                                                                                                  3/3

Installed:
  zlib-devel.x86_64 0:1.2.7-19.el7_9

Dependency Updated:
  zlib.x86_64 0:1.2.7-19.el7_9

Complete!
[root@pcs1 ~]#
[root@pcs1 ~]#

[root@pcs1 ~]# yum install -y install gcc
Loaded plugins: langpacks, ulninfo
No package install available.
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-28.0.1.el7 will be updated
--> Processing Dependency: gcc = 4.8.5-28.0.1.el7 for package: gcc-gfortran-4.8.5-28.0.1.el7.x86_64
--> Processing Dependency: gcc = 4.8.5-28.0.1.el7 for package: libquadmath-devel-4.8.5-28.0.1.el7.x86_64
--> Processing Dependency: gcc = 4.8.5-28.0.1.el7 for package: gcc-c++-4.8.5-28.0.1.el7.x86_64
---> Package gcc.x86_64 0:4.8.5-44.0.3.el7 will be an update
--> Processing Dependency: cpp = 4.8.5-44.0.3.el7 for package: gcc-4.8.5-44.0.3.el7.x86_64
--> Processing Dependency: libgomp = 4.8.5-44.0.3.el7 for package: gcc-4.8.5-44.0.3.el7.x86_64
--> Processing Dependency: libgcc >= 4.8.5-44.0.3.el7 for package: gcc-4.8.5-44.0.3.el7.x86_64
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-28.0.1.el7 will be updated
---> Package cpp.x86_64 0:4.8.5-44.0.3.el7 will be an update
---> Package gcc-c++.x86_64 0:4.8.5-28.0.1.el7 will be updated
---> Package gcc-c++.x86_64 0:4.8.5-44.0.3.el7 will be an update
--> Processing Dependency: libstdc++ = 4.8.5-44.0.3.el7 for package: gcc-c++-4.8.5-44.0.3.el7.x86_64
--> Processing Dependency: libstdc++-devel = 4.8.5-44.0.3.el7 for package: gcc-c++-4.8.5-44.0.3.el7.x86_64
---> Package gcc-gfortran.x86_64 0:4.8.5-28.0.1.el7 will be updated
---> Package gcc-gfortran.x86_64 0:4.8.5-44.0.3.el7 will be an update
--> Processing Dependency: libgfortran = 4.8.5-44.0.3.el7 for package: gcc-gfortran-4.8.5-44.0.3.el7.x86_64
--> Processing Dependency: libquadmath = 4.8.5-44.0.3.el7 for package: gcc-gfortran-4.8.5-44.0.3.el7.x86_64
---> Package libgcc.x86_64 0:4.8.5-28.0.1.el7 will be updated
---> Package libgcc.x86_64 0:4.8.5-44.0.3.el7 will be an update
---> Package libgomp.x86_64 0:4.8.5-28.0.1.el7 will be updated
---> Package libgomp.x86_64 0:4.8.5-44.0.3.el7 will be an update
---> Package libquadmath-devel.x86_64 0:4.8.5-28.0.1.el7 will be updated
---> Package libquadmath-devel.x86_64 0:4.8.5-44.0.3.el7 will be an update
--> Running transaction check
---> Package libgfortran.x86_64 0:4.8.5-28.0.1.el7 will be updated
---> Package libgfortran.x86_64 0:4.8.5-44.0.3.el7 will be an update
---> Package libquadmath.x86_64 0:4.8.5-28.0.1.el7 will be updated
---> Package libquadmath.x86_64 0:4.8.5-44.0.3.el7 will be an update
---> Package libstdc++.x86_64 0:4.8.5-28.0.1.el7 will be updated
---> Package libstdc++.x86_64 0:4.8.5-44.0.3.el7 will be an update
---> Package libstdc++-devel.x86_64 0:4.8.5-28.0.1.el7 will be updated
---> Package libstdc++-devel.x86_64 0:4.8.5-44.0.3.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================================================================
 Package                                                       Arch                                               Version                                                       Repository                                              Size
=============================================================================================================================================================================================================================================
Updating:
 gcc                                                           x86_64                                             4.8.5-44.0.3.el7                                              ol7_latest                                              16 M
Updating for dependencies:
 cpp                                                           x86_64                                             4.8.5-44.0.3.el7                                              ol7_latest                                             5.9 M
 gcc-c++                                                       x86_64                                             4.8.5-44.0.3.el7                                              ol7_latest                                             7.2 M
 gcc-gfortran                                                  x86_64                                             4.8.5-44.0.3.el7                                              ol7_latest                                             6.7 M
 libgcc                                                        x86_64                                             4.8.5-44.0.3.el7                                              ol7_latest                                             103 k
 libgfortran                                                   x86_64                                             4.8.5-44.0.3.el7                                              ol7_latest                                             301 k
 libgomp                                                       x86_64                                             4.8.5-44.0.3.el7                                              ol7_latest                                             159 k
 libquadmath                                                   x86_64                                             4.8.5-44.0.3.el7                                              ol7_latest                                             191 k
 libquadmath-devel                                             x86_64                                             4.8.5-44.0.3.el7                                              ol7_latest                                              54 k
 libstdc++                                                     x86_64                                             4.8.5-44.0.3.el7                                              ol7_latest                                             306 k
 libstdc++-devel                                               x86_64                                             4.8.5-44.0.3.el7                                              ol7_latest                                             1.5 M

Transaction Summary
=============================================================================================================================================================================================================================================
Upgrade  1 Package (+10 Dependent packages)

Total download size: 39 M
Downloading packages:
No Presto metadata available for ol7_latest
(1/11): gcc-4.8.5-44.0.3.el7.x86_64.rpm                                                                                                                                                                               |  16 MB  00:00:04
(2/11): cpp-4.8.5-44.0.3.el7.x86_64.rpm                                                                                                                                                                               | 5.9 MB  00:00:05
(3/11): gcc-c++-4.8.5-44.0.3.el7.x86_64.rpm                                                                                                                                                                           | 7.2 MB  00:00:01
(4/11): libgcc-4.8.5-44.0.3.el7.x86_64.rpm                                                                                                                                                                            | 103 kB  00:00:00
(5/11): libgfortran-4.8.5-44.0.3.el7.x86_64.rpm                                                                                                                                                                       | 301 kB  00:00:00
(6/11): libgomp-4.8.5-44.0.3.el7.x86_64.rpm                                                                                                                                                                           | 159 kB  00:00:00
(7/11): libquadmath-4.8.5-44.0.3.el7.x86_64.rpm                                                                                                                                                                       | 191 kB  00:00:00
(8/11): libquadmath-devel-4.8.5-44.0.3.el7.x86_64.rpm                                                                                                                                                                 |  54 kB  00:00:00
(9/11): libstdc++-4.8.5-44.0.3.el7.x86_64.rpm                                                                                                                                                                         | 306 kB  00:00:00
(10/11): gcc-gfortran-4.8.5-44.0.3.el7.x86_64.rpm                                                                                                                                                                     | 6.7 MB  00:00:02
(11/11): libstdc++-devel-4.8.5-44.0.3.el7.x86_64.rpm                                                                                                                                                                  | 1.5 MB  00:00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                        5.0 MB/s |  39 MB  00:00:07
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libgcc-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                           1/22
  Updating   : libquadmath-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                      2/22
  Updating   : libstdc++-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                        3/22
  Updating   : libstdc++-devel-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                  4/22
  Updating   : libgfortran-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                      5/22
  Updating   : cpp-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                              6/22
  Updating   : libgomp-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                          7/22
  Updating   : gcc-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                              8/22
  Updating   : libquadmath-devel-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                9/22
  Updating   : gcc-gfortran-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                    10/22
  Updating   : gcc-c++-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                         11/22
  Cleanup    : gcc-c++-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                         12/22
  Cleanup    : gcc-gfortran-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                    13/22
  Cleanup    : libquadmath-devel-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                               14/22
  Cleanup    : libstdc++-devel-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                 15/22
  Cleanup    : gcc-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                             16/22
  Cleanup    : libgfortran-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                     17/22
  Cleanup    : libstdc++-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                       18/22
  Cleanup    : libgcc-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                          19/22
  Cleanup    : libquadmath-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                     20/22
  Cleanup    : cpp-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                             21/22
  Cleanup    : libgomp-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                         22/22
  Verifying  : gcc-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                              1/22
  Verifying  : libquadmath-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                      2/22
  Verifying  : libstdc++-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                        3/22
  Verifying  : gcc-gfortran-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                     4/22
  Verifying  : libgomp-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                          5/22
  Verifying  : libstdc++-devel-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                  6/22
  Verifying  : libquadmath-devel-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                7/22
  Verifying  : gcc-c++-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                          8/22
  Verifying  : libgfortran-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                      9/22
  Verifying  : libgcc-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                          10/22
  Verifying  : cpp-4.8.5-44.0.3.el7.x86_64                                                                                                                                                                                             11/22
  Verifying  : gcc-gfortran-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                    12/22
  Verifying  : libgomp-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                         13/22
  Verifying  : libgcc-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                          14/22
  Verifying  : libstdc++-devel-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                 15/22
  Verifying  : gcc-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                             16/22
  Verifying  : cpp-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                             17/22
  Verifying  : libquadmath-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                     18/22
  Verifying  : gcc-c++-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                         19/22
  Verifying  : libgfortran-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                     20/22
  Verifying  : libstdc++-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                                       21/22
  Verifying  : libquadmath-devel-4.8.5-28.0.1.el7.x86_64                                                                                                                                                                               22/22

Updated:
  gcc.x86_64 0:4.8.5-44.0.3.el7

Dependency Updated:
  cpp.x86_64 0:4.8.5-44.0.3.el7         gcc-c++.x86_64 0:4.8.5-44.0.3.el7           gcc-gfortran.x86_64 0:4.8.5-44.0.3.el7 libgcc.x86_64 0:4.8.5-44.0.3.el7          libgfortran.x86_64 0:4.8.5-44.0.3.el7 libgomp.x86_64 0:4.8.5-44.0.3.el7
  libquadmath.x86_64 0:4.8.5-44.0.3.el7 libquadmath-devel.x86_64 0:4.8.5-44.0.3.el7 libstdc++.x86_64 0:4.8.5-44.0.3.el7    libstdc++-devel.x86_64 0:4.8.5-44.0.3.el7

Complete!
[root@pcs1 ~]#

[root@pcs1 ~]# yum install -y make
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package make.x86_64 1:3.82-23.el7 will be updated
---> Package make.x86_64 1:3.82-24.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================================================================
 Package                                              Arch                                                   Version                                                        Repository                                                  Size
=============================================================================================================================================================================================================================================
Updating:
 make                                                 x86_64                                                 1:3.82-24.el7                                                  ol7_latest                                                 420 k

Transaction Summary
=============================================================================================================================================================================================================================================
Upgrade  1 Package

Total download size: 420 k
Downloading packages:
No Presto metadata available for ol7_latest
make-3.82-24.el7.x86_64.rpm                                                                                                                                                                                           | 420 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 1:make-3.82-24.el7.x86_64                                                                                                                                                                                                 1/2
  Cleanup    : 1:make-3.82-23.el7.x86_64                                                                                                                                                                                                 2/2
  Verifying  : 1:make-3.82-24.el7.x86_64                                                                                                                                                                                                 1/2
  Verifying  : 1:make-3.82-23.el7.x86_64                                                                                                                                                                                                 2/2

Updated:
  make.x86_64 1:3.82-24.el7

Complete!
[root@pcs1 ~]#


2. Download the source code tar file

wget https://ftp.postgresql.org/pub/source/v13.3/postgresql-13.3.tar.gz

OR Download and then copy to server using winscp.

https://ftp.postgresql.org/pub/source/v13.3/postgresql-13.3.tar.gz


3. Extract tar file

[root@pcs1 ~]# tar -xvf postgresql-13.3.tar.gz
[root@pcs1 ~]#
-rw-r--r--. 1 root root 27610951 May 11  2021 postgresql-13.3.tar.gz
drwxrwxrwx. 6 1107 1107     4096 Dec 23 00:40 postgresql-13.3
[root@pcs1 ~]#



4. configure –help ..choose the options according to your needs.

[root@pcs1 ~]# cd postgresql-13.3/
[root@pcs1 postgresql-13.3]# ./configure --help
`configure' configures PostgreSQL 13.3 to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local/pgsql]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/pgsql/bin', `/usr/local/pgsql/lib' etc.  You can specify
an installation prefix other than `/usr/local/pgsql' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/postgresql]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --disable-integer-datetimes
                          obsolete option, no longer supported
  --enable-nls[=LANGUAGES]
                          enable Native Language Support
  --disable-rpath         do not embed shared library search path in
                          executables
  --disable-spinlocks     do not use spinlocks
  --disable-atomics       do not use atomic operations
  --enable-debug          build with debugging symbols (-g)
  --enable-profiling      build with profiling enabled
  --enable-coverage       build with coverage testing instrumentation
  --enable-dtrace         build with DTrace support
  --enable-tap-tests      enable TAP tests (requires Perl and IPC::Run)
  --enable-depend         turn on automatic dependency tracking
  --enable-cassert        enable assertion checks (for debugging)
  --disable-thread-safety disable thread-safety in client libraries
  --disable-largefile     omit support for large files

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-extra-version=STRING
                          append STRING to version
  --with-template=NAME    override operating system template
  --with-includes=DIRS    look for additional header files in DIRS
  --with-libraries=DIRS   look for additional libraries in DIRS
  --with-libs=DIRS        alternative spelling of --with-libraries
  --with-pgport=PORTNUM   set default port number [5432]
  --with-blocksize=BLOCKSIZE
                          set table block size in kB [8]
  --with-segsize=SEGSIZE  set table segment size in GB [1]
  --with-wal-blocksize=BLOCKSIZE
                          set WAL block size in kB [8]
  --with-CC=CMD           set compiler (deprecated)
  --with-llvm             build with LLVM based JIT support
  --with-icu              build with ICU support
  --with-tcl              build Tcl modules (PL/Tcl)
  --with-tclconfig=DIR    tclConfig.sh is in DIR
  --with-perl             build Perl modules (PL/Perl)
  --with-python           build Python modules (PL/Python)
  --with-gssapi           build with GSSAPI support
  --with-krb-srvnam=NAME  default service principal name in Kerberos (GSSAPI)
                          [postgres]
  --with-pam              build with PAM support
  --with-bsd-auth         build with BSD Authentication support
  --with-ldap             build with LDAP support
  --with-bonjour          build with Bonjour support
  --with-openssl          build with OpenSSL support
  --with-selinux          build with SELinux support
  --with-systemd          build with systemd support
  --without-readline      do not use GNU Readline nor BSD Libedit for editing
  --with-libedit-preferred
                          prefer BSD Libedit over GNU Readline
  --with-uuid=LIB         build contrib/uuid-ossp using LIB (bsd,e2fs,ossp)
  --with-ossp-uuid        obsolete spelling of --with-uuid=ossp
  --with-libxml           build with XML support
  --with-libxslt          use XSLT support when building contrib/xml2
  --with-system-tzdata=DIR
                          use system time zone data in DIR
  --without-zlib          do not use Zlib
  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L if you have libraries in a
              nonstandard directory 
  LIBS        libraries to pass to the linker, e.g. -l
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I if
              you have headers in a nonstandard directory 
  CXX         C++ compiler command
  CXXFLAGS    C++ compiler flags
  LLVM_CONFIG path to llvm-config command
  CLANG       path to clang compiler to generate bitcode
  CPP         C preprocessor
  PKG_CONFIG  path to pkg-config utility
  PKG_CONFIG_PATH
              directories to add to pkg-config's search path
  PKG_CONFIG_LIBDIR
              path overriding pkg-config's built-in search path
  ICU_CFLAGS  C compiler flags for ICU, overriding pkg-config
  ICU_LIBS    linker flags for ICU, overriding pkg-config
  XML2_CONFIG path to xml2-config utility
  XML2_CFLAGS C compiler flags for XML2, overriding pkg-config
  XML2_LIBS   linker flags for XML2, overriding pkg-config
  LDFLAGS_EX  extra linker flags for linking executables only
  LDFLAGS_SL  extra linker flags for linking shared libraries only
  PERL        Perl program
  PYTHON      Python program
  MSGFMT      msgfmt program for NLS
  TCLSH       Tcl interpreter program (tclsh)

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to <pgsql-bugs@lists.postgresql.org>.
PostgreSQL home page: <https://www.postgresql.org/>.
[root@pcs1 postgresql-13.3]#


5. Create postgres user and required directories

[root@pcs1 ~]# useradd -d /home/postgres/ postgres
[root@pcs1 ~]# passwd postgres
Changing password for user postgres.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@pcs1 ~]#
[root@pcs1 ~]# id postgres
uid=54322(postgres) gid=54323(postgres) groups=54323(postgres)
[root@pcs1 ~]#

[root@pcs1 ~]# mkdir -p /u01/app/postgres/13.3
[root@pcs1 ~]# mkdir -p /u02/app/psql/13.3/DATA


6. Configure PostgreSQL

[root@pcs1 ~]# cd postgresql-13.3
[root@pcs1 postgresql-13.3]# ls -ltr
total 744
-rw-r--r--.  1 1107 1107   1213 May 11  2021 README
-rw-r--r--.  1 1107 1107   1665 May 11  2021 Makefile
-rw-r--r--.  1 1107 1107    277 May 11  2021 HISTORY
-rw-r--r--.  1 1107 1107   4278 May 11  2021 GNUmakefile.in
-rw-r--r--.  1 1107 1107   1192 May 11  2021 COPYRIGHT
-rw-r--r--.  1 1107 1107  82388 May 11  2021 configure.in
-rwxr-xr-x.  1 1107 1107 568656 May 11  2021 configure
-rw-r--r--.  1 1107 1107    490 May 11  2021 aclocal.m4
drwxrwxrwx. 57 1107 1107   4096 May 11  2021 contrib
drwxrwxrwx.  2 1107 1107   4096 May 11  2021 config
drwxrwxrwx.  3 1107 1107     87 May 11  2021 doc
-rw-r--r--.  1 1107 1107  63684 May 11  2021 INSTALL
drwxrwxrwx. 16 1107 1107   4096 May 11  2021 src
[root@pcs1 postgresql-13.3]# ./configure --prefix=/u01/app/postgres/13.3 --with-pgport=5432
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for gcc option to accept ISO C99... -std=gnu99
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gawk... gawk
checking whether gcc -std=gnu99 supports -Wdeclaration-after-statement, for CFLAGS... yes
checking whether gcc -std=gnu99 supports -Werror=vla, for CFLAGS... yes
checking whether gcc -std=gnu99 supports -Wendif-labels, for CFLAGS... yes
checking whether g++ supports -Wendif-labels, for CXXFLAGS... yes
checking whether gcc -std=gnu99 supports -Wmissing-format-attribute, for CFLAGS... yes
checking whether g++ supports -Wmissing-format-attribute, for CXXFLAGS... yes
checking whether gcc -std=gnu99 supports -Wimplicit-fallthrough=3, for CFLAGS... no
checking whether g++ supports -Wimplicit-fallthrough=3, for CXXFLAGS... no
checking whether gcc -std=gnu99 supports -Wformat-security, for CFLAGS... yes
checking whether g++ supports -Wformat-security, for CXXFLAGS... yes
checking whether gcc -std=gnu99 supports -fno-strict-aliasing, for CFLAGS... yes
checking whether g++ supports -fno-strict-aliasing, for CXXFLAGS... yes
checking whether gcc -std=gnu99 supports -fwrapv, for CFLAGS... yes
checking whether g++ supports -fwrapv, for CXXFLAGS... yes
checking whether gcc -std=gnu99 supports -fexcess-precision=standard, for CFLAGS... yes
checking whether g++ supports -fexcess-precision=standard, for CXXFLAGS... no
checking whether gcc -std=gnu99 supports -funroll-loops, for CFLAGS_VECTOR... yes
checking whether gcc -std=gnu99 supports -ftree-vectorize, for CFLAGS_VECTOR... yes
checking whether gcc -std=gnu99 supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... no
checking whether gcc -std=gnu99 supports -Wformat-truncation, for NOT_THE_CFLAGS... no
checking whether gcc -std=gnu99 supports -Wstringop-truncation, for NOT_THE_CFLAGS... no
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking allow thread-safe client libraries... yes
checking whether to build with ICU support... no
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with PAM support... no
checking whether to build with BSD Authentication support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... no
checking whether to build with SELinux support... no
checking whether to build with systemd support... no
checking whether to build with XML support... no
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for ranlib... ranlib
checking for strip... strip
checking whether it is possible to strip libraries... yes
checking for ar... ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for tar... /usr/bin/tar
checking whether ln -s works... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for bison... /usr/bin/bison
configure: using bison (GNU Bison) 3.0.4
checking for flex... /usr/bin/flex
configure: using flex 2.5.37
checking for perl... /usr/bin/perl
configure: using perl 5.16.3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether gcc -std=gnu99 is Clang... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for strerror_r... yes
checking for getpwuid_r... yes
checking for gethostbyname_r... yes
checking whether strerror_r returns int... no
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... -ldl
checking for library containing socket... none required
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing shm_open... -lrt
checking for library containing shm_unlink... none required
checking for library containing clock_gettime... none required
checking for library containing fdatasync... none required
checking for library containing sched_yield... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for library containing backtrace_symbols... none required
checking for library containing readline... -lreadline
checking for inflate in -lz... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking atomic.h usability... no
checking atomic.h presence... no
checking for atomic.h... no
checking copyfile.h usability... no
checking copyfile.h presence... no
checking for copyfile.h... no
checking execinfo.h usability... yes
checking execinfo.h presence... yes
checking for execinfo.h... yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking ifaddrs.h usability... yes
checking ifaddrs.h presence... yes
checking for ifaddrs.h... yes
checking langinfo.h usability... yes
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking mbarrier.h usability... no
checking mbarrier.h presence... no
checking for mbarrier.h... no
checking poll.h usability... yes
checking poll.h presence... yes
checking for poll.h... yes
checking sys/epoll.h usability... yes
checking sys/epoll.h presence... yes
checking for sys/epoll.h... yes
checking sys/event.h usability... no
checking sys/event.h presence... no
checking for sys/event.h... no
checking sys/ipc.h usability... yes
checking sys/ipc.h presence... yes
checking for sys/ipc.h... yes
checking sys/prctl.h usability... yes
checking sys/prctl.h presence... yes
checking for sys/prctl.h... yes
checking sys/procctl.h usability... no
checking sys/procctl.h presence... no
checking for sys/procctl.h... no
checking sys/pstat.h usability... no
checking sys/pstat.h presence... no
checking for sys/pstat.h... no
checking sys/resource.h usability... yes
checking sys/resource.h presence... yes
checking for sys/resource.h... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/sem.h usability... yes
checking sys/sem.h presence... yes
checking for sys/sem.h... yes
checking sys/shm.h usability... yes
checking sys/shm.h presence... yes
checking for sys/shm.h... yes
checking sys/sockio.h usability... no
checking sys/sockio.h presence... no
checking for sys/sockio.h... no
checking sys/tas.h usability... no
checking sys/tas.h presence... no
checking for sys/tas.h... no
checking sys/un.h usability... yes
checking sys/un.h presence... yes
checking for sys/un.h... yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking ucred.h usability... no
checking ucred.h presence... no
checking for ucred.h... no
checking wctype.h usability... yes
checking wctype.h presence... yes
checking for wctype.h... yes
checking for net/if.h... yes
checking for sys/ucred.h... no
checking for netinet/tcp.h... yes
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes
checking readline/history.h usability... yes
checking readline/history.h presence... yes
checking for readline/history.h... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking whether byte ordering is bigendian... no
checking for inline... inline
checking for printf format archetype... gnu_printf
checking for __func__... yes
checking for _Static_assert... yes
checking for typeof... typeof
checking for __builtin_types_compatible_p... yes
checking for __builtin_constant_p... yes
checking for __builtin_unreachable... yes
checking for computed goto support... yes
checking for struct tm.tm_zone... yes
checking for union semun... no
checking for struct sockaddr_un... yes
checking for struct sockaddr_storage... yes
checking for struct sockaddr_storage.ss_family... yes
checking for struct sockaddr_storage.__ss_family... no
checking for struct sockaddr_storage.ss_len... no
checking for struct sockaddr_storage.__ss_len... no
checking for struct sockaddr.sa_len... no
checking for struct addrinfo... yes
checking for locale_t... yes
checking for C/C++ restrict keyword... __restrict
checking for struct cmsgcred... no
checking for struct option... yes
checking for z_streamp... yes
checking whether assembler supports x86_64 popcntq... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking size of off_t... 8
checking size of bool... 1
checking for int timezone... yes
checking types of arguments for accept()... int, int, struct sockaddr *, socklen_t *
checking whether gettimeofday takes only one argument... no
checking for wcstombs_l declaration... no
checking for backtrace_symbols... yes
checking for clock_gettime... yes
checking for copyfile... no
checking for fdatasync... yes
checking for getifaddrs... yes
checking for getpeerucred... no
checking for getrlimit... yes
checking for kqueue... no
checking for mbstowcs_l... no
checking for memset_s... no
checking for poll... yes
checking for posix_fallocate... yes
checking for ppoll... yes
checking for pstat... no
checking for pthread_is_threaded_np... no
checking for readlink... yes
checking for setproctitle... no
checking for setproctitle_fast... no
checking for setsid... yes
checking for shm_open... yes
checking for strchrnul... yes
checking for strsignal... yes
checking for symlink... yes
checking for sync_file_range... yes
checking for uselocale... yes
checking for wcstombs_l... no
checking for __builtin_bswap16... yes
checking for __builtin_bswap32... yes
checking for __builtin_bswap64... yes
checking for __builtin_clz... yes
checking for __builtin_ctz... yes
checking for __builtin_popcount... yes
checking for _LARGEFILE_SOURCE value needed for large files... no
checking how gcc -std=gnu99 reports undeclared, standard C functions... error
checking for posix_fadvise... yes
checking whether posix_fadvise is declared... yes
checking whether fdatasync is declared... yes
checking whether strlcat is declared... no
checking whether strlcpy is declared... no
checking whether strnlen is declared... yes
checking whether F_FULLFSYNC is declared... no
checking whether RTLD_GLOBAL is declared... yes
checking whether RTLD_NOW is declared... yes
checking for struct sockaddr_in6... yes
checking for PS_STRINGS... no
checking for dlopen... yes
checking for explicit_bzero... no
checking for fls... no
checking for getopt... yes
checking for getpeereid... no
checking for getrusage... yes
checking for inet_aton... yes
checking for link... yes
checking for mkdtemp... yes
checking for pread... yes
checking for pwrite... yes
checking for random... yes
checking for srandom... yes
checking for strlcat... no
checking for strlcpy... no
checking for strnlen... yes
checking for strtof... yes
checking for unsetenv... yes
checking for getaddrinfo... yes
checking for getopt_long... yes
checking for syslog... yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking for opterr... yes
checking for optreset... no
checking for strtoll... yes
checking for strtoull... yes
checking whether strtoll is declared... yes
checking whether strtoull is declared... yes
checking for rl_completion_append_character... yes
checking for rl_completion_suppress_quote... yes
checking for rl_filename_quote_characters... yes
checking for rl_filename_quoting_function... yes
checking for rl_completion_matches... yes
checking for rl_filename_completion_function... yes
checking for rl_reset_screen_size... yes
checking for append_history... yes
checking for history_truncate_file... yes
checking test program... ok
checking whether long int is 64 bits... yes
checking for __builtin_mul_overflow... no
checking size of void *... 8
checking size of size_t... 8
checking size of long... 8
checking alignment of short... 2
checking alignment of int... 4
checking alignment of long... 8
checking alignment of double... 8
checking for int8... no
checking for uint8... no
checking for int64... no
checking for uint64... no
checking for __int128... yes
checking for __int128 alignment bug... ok
checking alignment of PG_INT128_TYPE... 16
checking for builtin __sync char locking functions... yes
checking for builtin __sync int32 locking functions... yes
checking for builtin __sync int32 atomic operations... yes
checking for builtin __sync int64 atomic operations... yes
checking for builtin __atomic int32 atomic operations... yes
checking for builtin __atomic int64 atomic operations... yes
checking for __get_cpuid... yes
checking for __cpuid... no
checking for _mm_crc32_u8 and _mm_crc32_u32 with CFLAGS=... no
checking for _mm_crc32_u8 and _mm_crc32_u32 with CFLAGS=-msse4.2... yes
checking for __crc32cb, __crc32ch, __crc32cw, and __crc32cd with CFLAGS=... no
checking for __crc32cb, __crc32ch, __crc32cw, and __crc32cd with CFLAGS=-march=armv8-a+crc... no
checking which CRC-32C implementation to use... SSE 4.2 with runtime check
checking for library containing sem_init... -lpthread
checking which semaphore API to use... unnamed POSIX
checking for /dev/urandom... yes
checking which random number source to use... /dev/urandom
checking for xmllint... /usr/bin/xmllint
checking for xsltproc... /usr/bin/xsltproc
checking for fop... no
checking for dbtoepub... no
checking thread safety of required library functions... yes
checking whether gcc -std=gnu99 supports -Wl,--as-needed... yes
configure: using compiler=gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)
configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2
configure: using CPPFLAGS= -D_GNU_SOURCE
configure: using LDFLAGS=  -Wl,--as-needed
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: creating src/include/pg_config_ext.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking src/backend/port/posix_sema.c to src/backend/port/pg_sema.c
config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port
[root@pcs1 postgresql-13.3]#


7. Build postgreSQL using make command

[root@pcs1 postgresql-13.3]#
[root@pcs1 postgresql-13.3]# ls -ltr
total 1216
-rw-r--r--.  1 1107 1107   1213 May 11  2021 README
-rw-r--r--.  1 1107 1107   1665 May 11  2021 Makefile  -------
-rw-r--r--.  1 1107 1107    277 May 11  2021 HISTORY
-rw-r--r--.  1 1107 1107   4278 May 11  2021 GNUmakefile.in
-rw-r--r--.  1 1107 1107   1192 May 11  2021 COPYRIGHT
-rw-r--r--.  1 1107 1107  82388 May 11  2021 configure.in
-rwxr-xr-x.  1 1107 1107 568656 May 11  2021 configure
-rw-r--r--.  1 1107 1107    490 May 11  2021 aclocal.m4
drwxrwxrwx. 57 1107 1107   4096 May 11  2021 contrib
drwxrwxrwx.  2 1107 1107   4096 May 11  2021 config
drwxrwxrwx.  3 1107 1107     87 May 11  2021 doc
-rw-r--r--.  1 1107 1107  63684 May 11  2021 INSTALL
-rwxr-xr-x.  1 root root  40104 Dec 23 00:40 config.status
-rw-r--r--.  1 root root   4278 Dec 23 00:40 GNUmakefile
drwxrwxrwx. 16 1107 1107   4096 Dec 23 00:40 src
-rw-r--r--.  1 root root 433580 Dec 23 00:40 config.log
[root@pcs1 postgresql-13.3]#
[root@pcs1 postgresql-13.3]# which make
/usr/bin/make
[root@pcs1 postgresql-13.3]#
[root@pcs1 postgresql-13.3]# make
..
..
..
make -C test/perl all
make[2]: Entering directory `/root/postgresql-13.3/src/test/perl'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/root/postgresql-13.3/src/test/perl'
make[1]: Leaving directory `/root/postgresql-13.3/src'
make -C config all
make[1]: Entering directory `/root/postgresql-13.3/config'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/root/postgresql-13.3/config'
All of PostgreSQL successfully made. Ready to install.   <---------------------
[root@pcs1 postgresql-13.3]#


8. Install postgreSQL using make install command

[root@pcs1 postgresql-13.3]# pwd
/root/postgresql-13.3
[root@pcs1 postgresql-13.3]# ls -ltr /u01/app/postgres/13.3/
total 0   <--------
[root@pcs1 postgresql-13.3]#
[root@pcs1 postgresql-13.3]# make install
make -C ./src/backend generated-headers
make[1]: Entering directory `/root/postgresql-13.3/src/backend'
make -C catalog distprep generated-header-symlinks
make[2]: Entering directory `/root/postgresql-13.3/src/backend/catalog'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/root/postgresql-13.3/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[2]: Entering directory `/root/postgresql-13.3/src/backend/utils'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/root/postgresql-13.3/src/backend/utils'
make[1]: Leaving directory `/root/postgresql-13.3/src/backend'
make -C src install
make[1]: Entering directory `/root/postgresql-13.3/src'
make -C common install
make[2]: Entering directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 644  libpgcommon.a '/u01/app/postgres/13.3/lib/libpgcommon.a'
/usr/bin/install -c -m 644  libpgcommon_shlib.a '/u01/app/postgres/13.3/lib/libpgcommon_shlib.a'
make[2]: Leaving directory `/root/postgresql-13.3/src/common'
make -C port install
make[2]: Entering directory `/root/postgresql-13.3/src/port'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 644  libpgport.a '/u01/app/postgres/13.3/lib/libpgport.a'
/usr/bin/install -c -m 644  libpgport_shlib.a '/u01/app/postgres/13.3/lib/libpgport_shlib.a'
make[2]: Leaving directory `/root/postgresql-13.3/src/port'
make -C timezone install
make[2]: Entering directory `/root/postgresql-13.3/src/timezone'
make -C ../../src/port all
make[3]: Entering directory `/root/postgresql-13.3/src/port'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../src/common all
make[3]: Entering directory `/root/postgresql-13.3/src/common'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share'
./zic -d '/u01/app/postgres/13.3/share/timezone'  ./data/tzdata.zi
make -C tznames install
make[3]: Entering directory `/root/postgresql-13.3/src/timezone/tznames'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/timezonesets'
/usr/bin/install -c -m 644 ./Africa.txt ./America.txt ./Antarctica.txt ./Asia.txt ./Atlantic.txt ./Australia.txt ./Etc.txt ./Europe.txt ./Indian.txt ./Pacific.txt '/u01/app/postgres/13.3/share/timezonesets'
/usr/bin/install -c -m 644 ./Default ./Australia ./India '/u01/app/postgres/13.3/share/timezonesets'
make[3]: Leaving directory `/root/postgresql-13.3/src/timezone/tznames'
make[2]: Leaving directory `/root/postgresql-13.3/src/timezone'
make -C backend install
make[2]: Entering directory `/root/postgresql-13.3/src/backend'
make -C ../../src/port all
make[3]: Entering directory `/root/postgresql-13.3/src/port'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../src/common all
make[3]: Entering directory `/root/postgresql-13.3/src/common'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/common'
make -C catalog distprep generated-header-symlinks
make[3]: Entering directory `/root/postgresql-13.3/src/backend/catalog'
make[3]: Nothing to be done for `distprep'.
make[3]: Nothing to be done for `generated-header-symlinks'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils'
make[3]: Nothing to be done for `distprep'.
make[3]: Nothing to be done for `generated-header-symlinks'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils'
make -C access all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/access'
make -C brin all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/brin'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/brin'
make -C common all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/common'
make -C gin all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/gin'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/gin'
make -C gist all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/gist'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/gist'
make -C hash all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/hash'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/hash'
make -C heap all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/heap'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/heap'
make -C index all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/index'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/index'
make -C nbtree all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/nbtree'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/nbtree'
make -C rmgrdesc all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/rmgrdesc'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/rmgrdesc'
make -C spgist all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/spgist'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/spgist'
make -C table all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/table'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/table'
make -C tablesample all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/tablesample'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/tablesample'
make -C transam all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/transam'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/transam'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/access'
make -C bootstrap all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/bootstrap'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/bootstrap'
make -C catalog all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/catalog'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/catalog'
make -C parser all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/parser'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/parser'
make -C commands all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/commands'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/commands'
make -C executor all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/executor'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/executor'
make -C foreign all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/foreign'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/foreign'
make -C lib all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/lib'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/lib'
make -C libpq all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/libpq'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/libpq'
make -C main all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/main'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/main'
make -C nodes all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/nodes'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/nodes'
make -C optimizer all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/optimizer'
make -C geqo all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/optimizer/geqo'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer/geqo'
make -C path all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/optimizer/path'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer/path'
make -C plan all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/optimizer/plan'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer/plan'
make -C prep all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/optimizer/prep'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer/prep'
make -C util all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/optimizer/util'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer/util'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer'
make -C partitioning all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/partitioning'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/partitioning'
make -C port all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/port'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/port'
make -C postmaster all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/postmaster'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/postmaster'
make -C regex all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/regex'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/regex'
make -C replication all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/replication'
make -C logical all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/replication/logical'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/replication/logical'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/replication'
make -C rewrite all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/rewrite'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/rewrite'
make -C statistics all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/statistics'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/statistics'
make -C storage all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/storage'
make -C buffer all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/buffer'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/buffer'
make -C file all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/file'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/file'
make -C freespace all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/freespace'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/freespace'
make -C ipc all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/ipc'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/ipc'
make -C large_object all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/large_object'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/large_object'
make -C lmgr all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/lmgr'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/lmgr'
make -C page all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/page'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/page'
make -C smgr all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/smgr'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/smgr'
make -C sync all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/sync'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/sync'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/storage'
make -C tcop all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/tcop'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/tcop'
make -C tsearch all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/tsearch'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/tsearch'
make -C utils all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils'
make -C adt all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/adt'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/adt'
make -C cache all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/cache'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/cache'
make -C error all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/error'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/error'
make -C fmgr all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/fmgr'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/fmgr'
make -C hash all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/hash'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/hash'
make -C init all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/init'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/init'
make -C mb all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb'
make -C misc all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/misc'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/misc'
make -C mmgr all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/mmgr'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mmgr'
make -C resowner all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/resowner'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/resowner'
make -C sort all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/sort'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/sort'
make -C time all
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/time'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/time'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils'
make -C ../../src/timezone all
make[3]: Entering directory `/root/postgresql-13.3/src/timezone'
make -C ../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make[3]: Leaving directory `/root/postgresql-13.3/src/timezone'
make -C jit all
make[3]: Entering directory `/root/postgresql-13.3/src/backend/jit'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/jit'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin' '/u01/app/postgres/13.3/share'
/usr/bin/install -c  postgres '/u01/app/postgres/13.3/bin/postgres'
ln -s postgres '/u01/app/postgres/13.3/bin/postmaster'
make -C access install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/access'
make -C brin install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/brin'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/brin'
make -C common install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/common'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/common'
make -C gin install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/gin'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/gin'
make -C gist install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/gist'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/gist'
make -C hash install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/hash'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/hash'
make -C heap install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/heap'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/heap'
make -C index install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/index'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/index'
make -C nbtree install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/nbtree'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/nbtree'
make -C rmgrdesc install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/rmgrdesc'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/rmgrdesc'
make -C spgist install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/spgist'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/spgist'
make -C table install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/table'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/table'
make -C tablesample install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/tablesample'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/tablesample'
make -C transam install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/access/transam'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/access/transam'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/access'
make -C bootstrap install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/bootstrap'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/bootstrap'
make -C catalog install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/catalog'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/catalog'
make -C parser install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/parser'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/parser'
make -C commands install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/commands'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/commands'
make -C executor install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/executor'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/executor'
make -C foreign install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/foreign'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/foreign'
make -C lib install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/lib'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/lib'
make -C libpq install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/libpq'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/libpq'
make -C main install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/main'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/main'
make -C nodes install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/nodes'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/nodes'
make -C optimizer install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/optimizer'
make -C geqo install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/optimizer/geqo'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer/geqo'
make -C path install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/optimizer/path'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer/path'
make -C plan install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/optimizer/plan'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer/plan'
make -C prep install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/optimizer/prep'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer/prep'
make -C util install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/optimizer/util'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer/util'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/optimizer'
make -C partitioning install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/partitioning'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/partitioning'
make -C port install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/port'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/port'
make -C postmaster install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/postmaster'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/postmaster'
make -C regex install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/regex'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/regex'
make -C replication install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/replication'
make -C logical install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/replication/logical'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/replication/logical'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/replication'
make -C rewrite install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/rewrite'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/rewrite'
make -C statistics install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/statistics'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/statistics'
make -C storage install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/storage'
make -C buffer install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/buffer'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/buffer'
make -C file install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/file'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/file'
make -C freespace install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/freespace'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/freespace'
make -C ipc install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/ipc'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/ipc'
make -C large_object install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/large_object'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/large_object'
make -C lmgr install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/lmgr'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/lmgr'
make -C page install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/page'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/page'
make -C smgr install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/smgr'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/smgr'
make -C sync install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/storage/sync'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/storage/sync'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/storage'
make -C tcop install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/tcop'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/tcop'
make -C tsearch install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/tsearch'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/tsearch'
make -C utils install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils'
make -C adt install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/adt'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/adt'
make -C cache install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/cache'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/cache'
make -C error install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/error'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/error'
make -C fmgr install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/fmgr'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/fmgr'
make -C hash install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/hash'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/hash'
make -C init install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/init'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/init'
make -C mb install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb'
make -C misc install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/misc'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/misc'
make -C mmgr install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/mmgr'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mmgr'
make -C resowner install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/resowner'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/resowner'
make -C sort install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/sort'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/sort'
make -C time install
make[4]: Entering directory `/root/postgresql-13.3/src/backend/utils/time'
make[4]: Nothing to be done for `install'.
make[4]: Leaving directory `/root/postgresql-13.3/src/backend/utils/time'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils'
make -C ../../src/timezone install
make[3]: Entering directory `/root/postgresql-13.3/src/timezone'
make -C ../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share'
./zic -d '/u01/app/postgres/13.3/share/timezone'  ./data/tzdata.zi
make -C tznames install
make[4]: Entering directory `/root/postgresql-13.3/src/timezone/tznames'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/timezonesets'
/usr/bin/install -c -m 644 ./Africa.txt ./America.txt ./Antarctica.txt ./Asia.txt ./Atlantic.txt ./Australia.txt ./Etc.txt ./Europe.txt ./Indian.txt ./Pacific.txt '/u01/app/postgres/13.3/share/timezonesets'
/usr/bin/install -c -m 644 ./Default ./Australia ./India '/u01/app/postgres/13.3/share/timezonesets'
make[4]: Leaving directory `/root/postgresql-13.3/src/timezone/tznames'
make[3]: Leaving directory `/root/postgresql-13.3/src/timezone'
make -C jit install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/jit'
make[3]: Nothing to be done for `install'.
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/jit'
make -C catalog install-data
make[3]: Entering directory `/root/postgresql-13.3/src/backend/catalog'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share'
/usr/bin/install -c -m 644 `for f in ./postgres.bki; do test -r $f && echo $f && break; done` '/u01/app/postgres/13.3/share/postgres.bki'
/usr/bin/install -c -m 644 ./system_views.sql '/u01/app/postgres/13.3/share/system_views.sql'
/usr/bin/install -c -m 644 ./information_schema.sql '/u01/app/postgres/13.3/share/information_schema.sql'
/usr/bin/install -c -m 644 ./sql_features.txt '/u01/app/postgres/13.3/share/sql_features.txt'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/catalog'
make -C tsearch install-data
make[3]: Entering directory `/root/postgresql-13.3/src/backend/tsearch'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share' '/u01/app/postgres/13.3/share/tsearch_data'
/usr/bin/install -c -m 644 ./dicts/synonym_sample.syn ./dicts/thesaurus_sample.ths ./dicts/hunspell_sample.affix ./dicts/ispell_sample.affix ./dicts/ispell_sample.dict ./dicts/hunspell_sample_long.affix ./dicts/hunspell_sample_long.dict ./dicts/hunspell_sample_num.affix ./dicts/hunspell_sample_num.dict '/u01/app/postgres/13.3/share/tsearch_data/'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/tsearch'
make -C utils install-data
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share'
/usr/bin/install -c -m 644 ./errcodes.txt '/u01/app/postgres/13.3/share/errcodes.txt'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils'
/usr/bin/install -c -m 644 ./libpq/pg_hba.conf.sample '/u01/app/postgres/13.3/share/pg_hba.conf.sample'
/usr/bin/install -c -m 644 ./libpq/pg_ident.conf.sample '/u01/app/postgres/13.3/share/pg_ident.conf.sample'
/usr/bin/install -c -m 644 ./utils/misc/postgresql.conf.sample '/u01/app/postgres/13.3/share/postgresql.conf.sample'
make[2]: Leaving directory `/root/postgresql-13.3/src/backend'
make -C backend/utils/mb/conversion_procs install
make[2]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs'
make -C cyrillic_and_mic install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/cyrillic_and_mic'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  cyrillic_and_mic.so '/u01/app/postgres/13.3/lib/cyrillic_and_mic.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/cyrillic_and_mic'
make -C euc_cn_and_mic install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/euc_cn_and_mic'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  euc_cn_and_mic.so '/u01/app/postgres/13.3/lib/euc_cn_and_mic.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/euc_cn_and_mic'
make -C euc_jp_and_sjis install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  euc_jp_and_sjis.so '/u01/app/postgres/13.3/lib/euc_jp_and_sjis.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis'
make -C euc_kr_and_mic install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/euc_kr_and_mic'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  euc_kr_and_mic.so '/u01/app/postgres/13.3/lib/euc_kr_and_mic.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/euc_kr_and_mic'
make -C euc_tw_and_big5 install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/euc_tw_and_big5'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  euc_tw_and_big5.so '/u01/app/postgres/13.3/lib/euc_tw_and_big5.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/euc_tw_and_big5'
make -C latin2_and_win1250 install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/latin2_and_win1250'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  latin2_and_win1250.so '/u01/app/postgres/13.3/lib/latin2_and_win1250.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/latin2_and_win1250'
make -C latin_and_mic install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/latin_and_mic'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  latin_and_mic.so '/u01/app/postgres/13.3/lib/latin_and_mic.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/latin_and_mic'
make -C utf8_and_big5 install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_big5'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_big5.so '/u01/app/postgres/13.3/lib/utf8_and_big5.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_big5'
make -C utf8_and_cyrillic install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_cyrillic.so '/u01/app/postgres/13.3/lib/utf8_and_cyrillic.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic'
make -C utf8_and_euc_cn install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_euc_cn.so '/u01/app/postgres/13.3/lib/utf8_and_euc_cn.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn'
make -C utf8_and_euc_jp install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_euc_jp.so '/u01/app/postgres/13.3/lib/utf8_and_euc_jp.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp'
make -C utf8_and_euc_kr install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_euc_kr.so '/u01/app/postgres/13.3/lib/utf8_and_euc_kr.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr'
make -C utf8_and_euc_tw install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_euc_tw.so '/u01/app/postgres/13.3/lib/utf8_and_euc_tw.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw'
make -C utf8_and_gb18030 install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_gb18030'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_gb18030.so '/u01/app/postgres/13.3/lib/utf8_and_gb18030.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_gb18030'
make -C utf8_and_gbk install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_gbk'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_gbk.so '/u01/app/postgres/13.3/lib/utf8_and_gbk.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_gbk'
make -C utf8_and_iso8859 install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_iso8859'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_iso8859.so '/u01/app/postgres/13.3/lib/utf8_and_iso8859.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_iso8859'
make -C utf8_and_iso8859_1 install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_iso8859_1.so '/u01/app/postgres/13.3/lib/utf8_and_iso8859_1.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1'
make -C utf8_and_johab install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_johab'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_johab.so '/u01/app/postgres/13.3/lib/utf8_and_johab.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_johab'
make -C utf8_and_sjis install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_sjis'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_sjis.so '/u01/app/postgres/13.3/lib/utf8_and_sjis.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_sjis'
make -C utf8_and_win install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_win'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_win.so '/u01/app/postgres/13.3/lib/utf8_and_win.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_win'
make -C utf8_and_uhc install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_uhc'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_uhc.so '/u01/app/postgres/13.3/lib/utf8_and_uhc.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_uhc'
make -C utf8_and_euc2004 install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_euc2004'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_euc2004.so '/u01/app/postgres/13.3/lib/utf8_and_euc2004.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_euc2004'
make -C utf8_and_sjis2004 install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_sjis2004'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  utf8_and_sjis2004.so '/u01/app/postgres/13.3/lib/utf8_and_sjis2004.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/utf8_and_sjis2004'
make -C euc2004_sjis2004 install
make[3]: Entering directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/euc2004_sjis2004'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  euc2004_sjis2004.so '/u01/app/postgres/13.3/lib/euc2004_sjis2004.so'
make[3]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs/euc2004_sjis2004'
make[2]: Leaving directory `/root/postgresql-13.3/src/backend/utils/mb/conversion_procs'
make -C backend/snowball install
make[2]: Entering directory `/root/postgresql-13.3/src/backend/snowball'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share' '/u01/app/postgres/13.3/share/tsearch_data'
/usr/bin/install -c -m 755  dict_snowball.so '/u01/app/postgres/13.3/lib/dict_snowball.so'
/usr/bin/install -c -m 644 snowball_create.sql '/u01/app/postgres/13.3/share'
make[2]: Leaving directory `/root/postgresql-13.3/src/backend/snowball'
make -C include install
make[2]: Entering directory `/root/postgresql-13.3/src/include'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/include/libpq' '/u01/app/postgres/13.3/include/internal/libpq'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/include/server'/access '/u01/app/postgres/13.3/include/server'/bootstrap '/u01/app/postgres/13.3/include/server'/catalog '/u01/app/postgres/13.3/include/server'/commands '/u01/app/postgres/13.3/include/server'/common '/u01/app/postgres/13.3/include/server'/datatype '/u01/app/postgres/13.3/include/server'/executor '/u01/app/postgres/13.3/include/server'/fe_utils '/u01/app/postgres/13.3/include/server'/foreign '/u01/app/postgres/13.3/include/server'/jit '/u01/app/postgres/13.3/include/server'/lib '/u01/app/postgres/13.3/include/server'/libpq '/u01/app/postgres/13.3/include/server'/mb '/u01/app/postgres/13.3/include/server'/nodes '/u01/app/postgres/13.3/include/server'/optimizer '/u01/app/postgres/13.3/include/server'/parser '/u01/app/postgres/13.3/include/server'/partitioning '/u01/app/postgres/13.3/include/server'/postmaster '/u01/app/postgres/13.3/include/server'/regex '/u01/app/postgres/13.3/include/server'/replication '/u01/app/postgres/13.3/include/server'/rewrite '/u01/app/postgres/13.3/include/server'/statistics '/u01/app/postgres/13.3/include/server'/storage '/u01/app/postgres/13.3/include/server'/tcop '/u01/app/postgres/13.3/include/server'/snowball '/u01/app/postgres/13.3/include/server'/snowball/libstemmer '/u01/app/postgres/13.3/include/server'/tsearch '/u01/app/postgres/13.3/include/server'/tsearch/dicts '/u01/app/postgres/13.3/include/server'/utils '/u01/app/postgres/13.3/include/server'/port '/u01/app/postgres/13.3/include/server'/port/atomics '/u01/app/postgres/13.3/include/server'/port/win32 '/u01/app/postgres/13.3/include/server'/port/win32_msvc '/u01/app/postgres/13.3/include/server'/port/win32_msvc/sys '/u01/app/postgres/13.3/include/server'/port/win32/arpa '/u01/app/postgres/13.3/include/server'/port/win32/netinet '/u01/app/postgres/13.3/include/server'/port/win32/sys '/u01/app/postgres/13.3/include/server'/portability
/usr/bin/install -c -m 644 ./postgres_ext.h   '/u01/app/postgres/13.3/include'
/usr/bin/install -c -m 644 ./libpq/libpq-fs.h '/u01/app/postgres/13.3/include/libpq'
/usr/bin/install -c -m 644 pg_config.h     '/u01/app/postgres/13.3/include'
/usr/bin/install -c -m 644 pg_config_ext.h '/u01/app/postgres/13.3/include'
/usr/bin/install -c -m 644 pg_config_os.h  '/u01/app/postgres/13.3/include'
/usr/bin/install -c -m 644 ./pg_config_manual.h '/u01/app/postgres/13.3/include'
/usr/bin/install -c -m 644 ./c.h            '/u01/app/postgres/13.3/include/internal'
/usr/bin/install -c -m 644 ./port.h         '/u01/app/postgres/13.3/include/internal'
/usr/bin/install -c -m 644 ./postgres_fe.h  '/u01/app/postgres/13.3/include/internal'
/usr/bin/install -c -m 644 ./libpq/pqcomm.h '/u01/app/postgres/13.3/include/internal/libpq'
/usr/bin/install -c -m 644 pg_config.h     '/u01/app/postgres/13.3/include/server'
/usr/bin/install -c -m 644 pg_config_ext.h '/u01/app/postgres/13.3/include/server'
/usr/bin/install -c -m 644 pg_config_os.h  '/u01/app/postgres/13.3/include/server'
/usr/bin/install -c -m 644 utils/errcodes.h '/u01/app/postgres/13.3/include/server/utils'
/usr/bin/install -c -m 644 utils/fmgroids.h '/u01/app/postgres/13.3/include/server/utils'
/usr/bin/install -c -m 644 utils/fmgrprotos.h '/u01/app/postgres/13.3/include/server/utils'
cp ./*.h '/u01/app/postgres/13.3/include/server'/
for dir in access bootstrap catalog commands common datatype executor fe_utils foreign jit lib libpq mb nodes optimizer parser partitioning postmaster regex replication rewrite statistics storage tcop snowball snowball/libstemmer tsearch tsearch/dicts utils port port/atomics port/win32 port/win32_msvc port/win32_msvc/sys port/win32/arpa port/win32/netinet port/win32/sys portability; do \
  cp ./$dir/*.h '/u01/app/postgres/13.3/include/server'/$dir/ || exit; \
done
cd '/u01/app/postgres/13.3/include/server' && chmod 644 *.h
for dir in access bootstrap catalog commands common datatype executor fe_utils foreign jit lib libpq mb nodes optimizer parser partitioning postmaster regex replication rewrite statistics storage tcop snowball snowball/libstemmer tsearch tsearch/dicts utils port port/atomics port/win32 port/win32_msvc port/win32_msvc/sys port/win32/arpa port/win32/netinet port/win32/sys portability; do \
  cd '/u01/app/postgres/13.3/include/server'/$dir || exit; \
  chmod 644 *.h || exit; \
done
make[2]: Leaving directory `/root/postgresql-13.3/src/include'
make -C interfaces install
make[2]: Entering directory `/root/postgresql-13.3/src/interfaces'
make -C libpq install
make[3]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib' '/u01/app/postgres/13.3/lib/pkgconfig'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/include' '/u01/app/postgres/13.3/include/internal' '/u01/app/postgres/13.3/share'
/usr/bin/install -c -m 755  libpq.so.5.13 '/u01/app/postgres/13.3/lib/libpq.so.5.13'
cd '/u01/app/postgres/13.3/lib' && \
rm -f libpq.so.5 && \
ln -s libpq.so.5.13 libpq.so.5
cd '/u01/app/postgres/13.3/lib' && \
rm -f libpq.so && \
ln -s libpq.so.5.13 libpq.so
/usr/bin/install -c -m 644  libpq.a '/u01/app/postgres/13.3/lib/libpq.a'
/usr/bin/install -c -m 644 libpq.pc '/u01/app/postgres/13.3/lib/pkgconfig/libpq.pc'
/usr/bin/install -c -m 644 ./libpq-fe.h '/u01/app/postgres/13.3/include'
/usr/bin/install -c -m 644 ./libpq-events.h '/u01/app/postgres/13.3/include'
/usr/bin/install -c -m 644 ./libpq-int.h '/u01/app/postgres/13.3/include/internal'
/usr/bin/install -c -m 644 ./pqexpbuffer.h '/u01/app/postgres/13.3/include/internal'
/usr/bin/install -c -m 644 ./pg_service.conf.sample '/u01/app/postgres/13.3/share/pg_service.conf.sample'
make[3]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ecpg install
make[3]: Entering directory `/root/postgresql-13.3/src/interfaces/ecpg'
make -C include install
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/ecpg/include'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/include' '/u01/app/postgres/13.3/include/informix/esql'
/usr/bin/install -c -m 644 ./ecpgerrno.h ./ecpglib.h ./ecpgtype.h ./sqlca.h ./sql3types.h ./ecpg_informix.h ./pgtypes_error.h ./pgtypes_numeric.h ./pgtypes_timestamp.h ./pgtypes_date.h ./pgtypes_interval.h ./pgtypes.h ./sqlda.h ./sqlda-compat.h ./sqlda-native.h '/u01/app/postgres/13.3/include/'
/usr/bin/install -c -m 644 ./datetime.h ./decimal.h ./sqltypes.h '/u01/app/postgres/13.3/include/informix/esql/'
/usr/bin/install -c -m 644 ../../../../src/interfaces/ecpg/include/ecpg_config.h '/u01/app/postgres/13.3/include'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/ecpg/include'
make -C pgtypeslib install
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/ecpg/pgtypeslib'
make -C ../../../../src/port all
make[5]: Entering directory `/root/postgresql-13.3/src/port'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../../src/common all
make[5]: Entering directory `/root/postgresql-13.3/src/common'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib' '/u01/app/postgres/13.3/lib/pkgconfig'
/usr/bin/install -c -m 755  libpgtypes.so.3.13 '/u01/app/postgres/13.3/lib/libpgtypes.so.3.13'
cd '/u01/app/postgres/13.3/lib' && \
rm -f libpgtypes.so.3 && \
ln -s libpgtypes.so.3.13 libpgtypes.so.3
cd '/u01/app/postgres/13.3/lib' && \
rm -f libpgtypes.so && \
ln -s libpgtypes.so.3.13 libpgtypes.so
/usr/bin/install -c -m 644  libpgtypes.a '/u01/app/postgres/13.3/lib/libpgtypes.a'
/usr/bin/install -c -m 644 libpgtypes.pc '/u01/app/postgres/13.3/lib/pkgconfig/libpgtypes.pc'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/ecpg/pgtypeslib'
make -C ecpglib install
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/ecpg/ecpglib'
make -C ../../../../src/interfaces/libpq all
make[5]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[6]: Entering directory `/root/postgresql-13.3/src/port'
make[6]: Nothing to be done for `all'.
make[6]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[6]: Entering directory `/root/postgresql-13.3/src/common'
make[6]: Nothing to be done for `all'.
make[6]: Leaving directory `/root/postgresql-13.3/src/common'
make[5]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../../src/interfaces/ecpg/pgtypeslib all
make[5]: Entering directory `/root/postgresql-13.3/src/interfaces/ecpg/pgtypeslib'
make -C ../../../../src/port all
make[6]: Entering directory `/root/postgresql-13.3/src/port'
make[6]: Nothing to be done for `all'.
make[6]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../../src/common all
make[6]: Entering directory `/root/postgresql-13.3/src/common'
make[6]: Nothing to be done for `all'.
make[6]: Leaving directory `/root/postgresql-13.3/src/common'
make[5]: Leaving directory `/root/postgresql-13.3/src/interfaces/ecpg/pgtypeslib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib' '/u01/app/postgres/13.3/lib/pkgconfig'
/usr/bin/install -c -m 755  libecpg.so.6.13 '/u01/app/postgres/13.3/lib/libecpg.so.6.13'
cd '/u01/app/postgres/13.3/lib' && \
rm -f libecpg.so.6 && \
ln -s libecpg.so.6.13 libecpg.so.6
cd '/u01/app/postgres/13.3/lib' && \
rm -f libecpg.so && \
ln -s libecpg.so.6.13 libecpg.so
/usr/bin/install -c -m 644  libecpg.a '/u01/app/postgres/13.3/lib/libecpg.a'
/usr/bin/install -c -m 644 libecpg.pc '/u01/app/postgres/13.3/lib/pkgconfig/libecpg.pc'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/ecpg/ecpglib'
make -C compatlib install
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/ecpg/compatlib'
make -C ../../../../src/interfaces/ecpg/ecpglib all
make[5]: Entering directory `/root/postgresql-13.3/src/interfaces/ecpg/ecpglib'
make -C ../../../../src/interfaces/libpq all
make[6]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[7]: Entering directory `/root/postgresql-13.3/src/port'
make[7]: Nothing to be done for `all'.
make[7]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[7]: Entering directory `/root/postgresql-13.3/src/common'
make[7]: Nothing to be done for `all'.
make[7]: Leaving directory `/root/postgresql-13.3/src/common'
make[6]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../../src/interfaces/ecpg/pgtypeslib all
make[6]: Entering directory `/root/postgresql-13.3/src/interfaces/ecpg/pgtypeslib'
make -C ../../../../src/port all
make[7]: Entering directory `/root/postgresql-13.3/src/port'
make[7]: Nothing to be done for `all'.
make[7]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../../src/common all
make[7]: Entering directory `/root/postgresql-13.3/src/common'
make[7]: Nothing to be done for `all'.
make[7]: Leaving directory `/root/postgresql-13.3/src/common'
make[6]: Leaving directory `/root/postgresql-13.3/src/interfaces/ecpg/pgtypeslib'
make[5]: Leaving directory `/root/postgresql-13.3/src/interfaces/ecpg/ecpglib'
make -C ../../../../src/interfaces/ecpg/pgtypeslib all
make[5]: Entering directory `/root/postgresql-13.3/src/interfaces/ecpg/pgtypeslib'
make -C ../../../../src/port all
make[6]: Entering directory `/root/postgresql-13.3/src/port'
make[6]: Nothing to be done for `all'.
make[6]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../../src/common all
make[6]: Entering directory `/root/postgresql-13.3/src/common'
make[6]: Nothing to be done for `all'.
make[6]: Leaving directory `/root/postgresql-13.3/src/common'
make[5]: Leaving directory `/root/postgresql-13.3/src/interfaces/ecpg/pgtypeslib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib' '/u01/app/postgres/13.3/lib/pkgconfig'
/usr/bin/install -c -m 755  libecpg_compat.so.3.13 '/u01/app/postgres/13.3/lib/libecpg_compat.so.3.13'
cd '/u01/app/postgres/13.3/lib' && \
rm -f libecpg_compat.so.3 && \
ln -s libecpg_compat.so.3.13 libecpg_compat.so.3
cd '/u01/app/postgres/13.3/lib' && \
rm -f libecpg_compat.so && \
ln -s libecpg_compat.so.3.13 libecpg_compat.so
/usr/bin/install -c -m 644  libecpg_compat.a '/u01/app/postgres/13.3/lib/libecpg_compat.a'
/usr/bin/install -c -m 644 libecpg_compat.pc '/u01/app/postgres/13.3/lib/pkgconfig/libecpg_compat.pc'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/ecpg/compatlib'
make -C preproc install
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/ecpg/preproc'
make -C ../../../../src/port all
make[5]: Entering directory `/root/postgresql-13.3/src/port'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../../src/common all
make[5]: Entering directory `/root/postgresql-13.3/src/common'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  ecpg '/u01/app/postgres/13.3/bin'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/ecpg/preproc'
make[3]: Leaving directory `/root/postgresql-13.3/src/interfaces/ecpg'
make[2]: Leaving directory `/root/postgresql-13.3/src/interfaces'
make -C backend/replication/libpqwalreceiver install
make[2]: Entering directory `/root/postgresql-13.3/src/backend/replication/libpqwalreceiver'
make -C ../../../../src/interfaces/libpq all
make[3]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make[3]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  libpqwalreceiver.so '/u01/app/postgres/13.3/lib/libpqwalreceiver.so'
make[2]: Leaving directory `/root/postgresql-13.3/src/backend/replication/libpqwalreceiver'
make -C backend/replication/pgoutput install
make[2]: Entering directory `/root/postgresql-13.3/src/backend/replication/pgoutput'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  pgoutput.so '/u01/app/postgres/13.3/lib/pgoutput.so'
make[2]: Leaving directory `/root/postgresql-13.3/src/backend/replication/pgoutput'
make -C fe_utils install
make[2]: Entering directory `/root/postgresql-13.3/src/fe_utils'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 644  libpgfeutils.a '/u01/app/postgres/13.3/lib/libpgfeutils.a'
make[2]: Leaving directory `/root/postgresql-13.3/src/fe_utils'
make -C bin install
make[2]: Entering directory `/root/postgresql-13.3/src/bin'
make -C initdb install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/initdb'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[5]: Entering directory `/root/postgresql-13.3/src/port'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[5]: Entering directory `/root/postgresql-13.3/src/common'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/common'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory `/root/postgresql-13.3/src/fe_utils'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/fe_utils'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  initdb '/u01/app/postgres/13.3/bin/initdb'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/initdb'
make -C pg_archivecleanup install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_archivecleanup'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_archivecleanup '/u01/app/postgres/13.3/bin/pg_archivecleanup'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_archivecleanup'
make -C pg_basebackup install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_basebackup'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[5]: Entering directory `/root/postgresql-13.3/src/port'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[5]: Entering directory `/root/postgresql-13.3/src/common'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/common'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory `/root/postgresql-13.3/src/fe_utils'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/fe_utils'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_basebackup '/u01/app/postgres/13.3/bin/pg_basebackup'
/usr/bin/install -c  pg_receivewal '/u01/app/postgres/13.3/bin/pg_receivewal'
/usr/bin/install -c  pg_recvlogical '/u01/app/postgres/13.3/bin/pg_recvlogical'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_basebackup'
make -C pg_checksums install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_checksums'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_checksums '/u01/app/postgres/13.3/bin/pg_checksums'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_checksums'
make -C pg_config install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_config'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c -m 755 pg_config '/u01/app/postgres/13.3/bin/pg_config'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_config'
make -C pg_controldata install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_controldata'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_controldata '/u01/app/postgres/13.3/bin/pg_controldata'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_controldata'
make -C pg_ctl install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_ctl'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_ctl '/u01/app/postgres/13.3/bin/pg_ctl'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_ctl'
make -C pg_dump install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_dump'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[5]: Entering directory `/root/postgresql-13.3/src/port'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[5]: Entering directory `/root/postgresql-13.3/src/common'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/common'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory `/root/postgresql-13.3/src/fe_utils'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/fe_utils'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_dump '/u01/app/postgres/13.3/bin'/pg_dump
/usr/bin/install -c  pg_restore '/u01/app/postgres/13.3/bin'/pg_restore
/usr/bin/install -c  pg_dumpall '/u01/app/postgres/13.3/bin'/pg_dumpall
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_dump'
make -C pg_resetwal install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_resetwal'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_resetwal '/u01/app/postgres/13.3/bin/pg_resetwal'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_resetwal'
make -C pg_rewind install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_rewind'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[5]: Entering directory `/root/postgresql-13.3/src/port'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[5]: Entering directory `/root/postgresql-13.3/src/common'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/common'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_rewind '/u01/app/postgres/13.3/bin/pg_rewind'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_rewind'
make -C pg_test_fsync install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_test_fsync'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_test_fsync '/u01/app/postgres/13.3/bin/pg_test_fsync'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_test_fsync'
make -C pg_test_timing install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_test_timing'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_test_timing '/u01/app/postgres/13.3/bin/pg_test_timing'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_test_timing'
make -C pg_upgrade install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_upgrade'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[5]: Entering directory `/root/postgresql-13.3/src/port'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[5]: Entering directory `/root/postgresql-13.3/src/common'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/common'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory `/root/postgresql-13.3/src/fe_utils'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/fe_utils'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_upgrade '/u01/app/postgres/13.3/bin/pg_upgrade'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_upgrade'
make -C pg_verifybackup install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_verifybackup'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[5]: Entering directory `/root/postgresql-13.3/src/port'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[5]: Entering directory `/root/postgresql-13.3/src/common'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/common'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory `/root/postgresql-13.3/src/fe_utils'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/fe_utils'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_verifybackup '/u01/app/postgres/13.3/bin/pg_verifybackup'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_verifybackup'
make -C pg_waldump install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pg_waldump'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_waldump '/u01/app/postgres/13.3/bin/pg_waldump'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pg_waldump'
make -C pgbench install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/pgbench'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[5]: Entering directory `/root/postgresql-13.3/src/port'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[5]: Entering directory `/root/postgresql-13.3/src/common'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/common'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory `/root/postgresql-13.3/src/fe_utils'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/fe_utils'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pgbench '/u01/app/postgres/13.3/bin/pgbench'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/pgbench'
make -C psql install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/psql'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[5]: Entering directory `/root/postgresql-13.3/src/port'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[5]: Entering directory `/root/postgresql-13.3/src/common'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/common'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory `/root/postgresql-13.3/src/fe_utils'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/fe_utils'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin' '/u01/app/postgres/13.3/share'
/usr/bin/install -c  psql '/u01/app/postgres/13.3/bin/psql'
/usr/bin/install -c -m 644 ./psqlrc.sample '/u01/app/postgres/13.3/share/psqlrc.sample'
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/psql'
make -C scripts install
make[3]: Entering directory `/root/postgresql-13.3/src/bin/scripts'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[5]: Entering directory `/root/postgresql-13.3/src/port'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[5]: Entering directory `/root/postgresql-13.3/src/common'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/root/postgresql-13.3/src/common'
make[4]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory `/root/postgresql-13.3/src/fe_utils'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/fe_utils'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  createdb   '/u01/app/postgres/13.3/bin'/createdb
/usr/bin/install -c  dropdb     '/u01/app/postgres/13.3/bin'/dropdb
/usr/bin/install -c  createuser '/u01/app/postgres/13.3/bin'/createuser
/usr/bin/install -c  dropuser   '/u01/app/postgres/13.3/bin'/dropuser
/usr/bin/install -c  clusterdb  '/u01/app/postgres/13.3/bin'/clusterdb
/usr/bin/install -c  vacuumdb   '/u01/app/postgres/13.3/bin'/vacuumdb
/usr/bin/install -c  reindexdb  '/u01/app/postgres/13.3/bin'/reindexdb
/usr/bin/install -c  pg_isready '/u01/app/postgres/13.3/bin'/pg_isready
make[3]: Leaving directory `/root/postgresql-13.3/src/bin/scripts'
make[2]: Leaving directory `/root/postgresql-13.3/src/bin'
make -C pl install
make[2]: Entering directory `/root/postgresql-13.3/src/pl'
make -C plpgsql install
make[3]: Entering directory `/root/postgresql-13.3/src/pl/plpgsql'
make -C src install
make[4]: Entering directory `/root/postgresql-13.3/src/pl/plpgsql/src'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  plpgsql.so '/u01/app/postgres/13.3/lib/plpgsql.so'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/include/server'
/usr/bin/install -c -m 644 ./plpgsql.control ./plpgsql--1.0.sql '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 './plpgsql.h' '/u01/app/postgres/13.3/include/server'
make[4]: Leaving directory `/root/postgresql-13.3/src/pl/plpgsql/src'
make[3]: Leaving directory `/root/postgresql-13.3/src/pl/plpgsql'
make[2]: Leaving directory `/root/postgresql-13.3/src/pl'
make -C makefiles install
make[2]: Entering directory `/root/postgresql-13.3/src/makefiles'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib/pgxs/src/makefiles'
/usr/bin/install -c -m 644 ./pgxs.mk '/u01/app/postgres/13.3/lib/pgxs/src/makefiles/'
make[2]: Leaving directory `/root/postgresql-13.3/src/makefiles'
make -C test/regress install
make[2]: Entering directory `/root/postgresql-13.3/src/test/regress'
make -C ../../../src/port all
make[3]: Entering directory `/root/postgresql-13.3/src/port'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[3]: Entering directory `/root/postgresql-13.3/src/common'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/common'
make -C ../../../contrib/spi
make[3]: Entering directory `/root/postgresql-13.3/contrib/spi'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/contrib/spi'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib/pgxs/src/test/regress'
/usr/bin/install -c  pg_regress '/u01/app/postgres/13.3/lib/pgxs/src/test/regress/pg_regress'
make[2]: Leaving directory `/root/postgresql-13.3/src/test/regress'
make -C test/isolation install
make[2]: Entering directory `/root/postgresql-13.3/src/test/isolation'
make -C ../../../src/interfaces/libpq all
make[3]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory `/root/postgresql-13.3/src/port'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[4]: Entering directory `/root/postgresql-13.3/src/common'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/root/postgresql-13.3/src/common'
make[3]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[3]: Entering directory `/root/postgresql-13.3/src/port'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[3]: Entering directory `/root/postgresql-13.3/src/common'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/common'
make[2]: Leaving directory `/root/postgresql-13.3/src/test/isolation'
make -C test/perl install
make[2]: Entering directory `/root/postgresql-13.3/src/test/perl'
make[2]: Nothing to be done for `install'.
make[2]: Leaving directory `/root/postgresql-13.3/src/test/perl'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib/pgxs/src'
/usr/bin/install -c -m 644 Makefile.global '/u01/app/postgres/13.3/lib/pgxs/src/Makefile.global'
/usr/bin/install -c -m 644 Makefile.port '/u01/app/postgres/13.3/lib/pgxs/src/Makefile.port'
/usr/bin/install -c -m 644 ./Makefile.shlib '/u01/app/postgres/13.3/lib/pgxs/src/Makefile.shlib'
/usr/bin/install -c -m 644 ./nls-global.mk '/u01/app/postgres/13.3/lib/pgxs/src/nls-global.mk'
make[1]: Leaving directory `/root/postgresql-13.3/src'
make -C config install
make[1]: Entering directory `/root/postgresql-13.3/config'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib/pgxs/config'
/usr/bin/install -c -m 755 ./install-sh '/u01/app/postgres/13.3/lib/pgxs/config/install-sh'
/usr/bin/install -c -m 755 ./missing '/u01/app/postgres/13.3/lib/pgxs/config/missing'
make[1]: Leaving directory `/root/postgresql-13.3/config'
PostgreSQL installation complete.  <-----
[root@pcs1 postgresql-13.3]#

[root@pcs1 postgresql-13.3]# ls -ltr /u01/app/postgres/13.3/
total 16
drwxr-xr-x. 6 root root 4096 Dec 23 01:01 include
drwxr-xr-x. 2 root root 4096 Dec 23 01:01 bin
drwxr-xr-x. 6 root root 4096 Dec 23 01:01 share
drwxr-xr-x. 4 root root 4096 Dec 23 01:01 lib
[root@pcs1 postgresql-13.3]#


9. Build contrib module using make command (optional)

[root@pcs1 postgresql-13.3]# pwd
/root/postgresql-13.3
[root@pcs1 postgresql-13.3]#

[root@pcs1 postgresql-13.3]# ls -ltr
total 1216
-rw-r--r--.  1 1107 1107   1213 May 11  2021 README
-rw-r--r--.  1 1107 1107   1665 May 11  2021 Makefile
-rw-r--r--.  1 1107 1107    277 May 11  2021 HISTORY
-rw-r--r--.  1 1107 1107   4278 May 11  2021 GNUmakefile.in
-rw-r--r--.  1 1107 1107   1192 May 11  2021 COPYRIGHT
-rw-r--r--.  1 1107 1107  82388 May 11  2021 configure.in
-rwxr-xr-x.  1 1107 1107 568656 May 11  2021 configure
-rw-r--r--.  1 1107 1107    490 May 11  2021 aclocal.m4
drwxrwxrwx. 57 1107 1107   4096 May 11  2021 contrib
drwxrwxrwx.  2 1107 1107   4096 May 11  2021 config
drwxrwxrwx.  3 1107 1107     87 May 11  2021 doc
-rw-r--r--.  1 1107 1107  63684 May 11  2021 INSTALL
-rwxr-xr-x.  1 root root  40104 Dec 23 00:40 config.status
-rw-r--r--.  1 root root   4278 Dec 23 00:40 GNUmakefile
drwxrwxrwx. 16 1107 1107   4096 Dec 23 00:40 src
-rw-r--r--.  1 root root 433580 Dec 23 00:40 config.log
[root@pcs1 postgresql-13.3]# cd contrib/
[root@pcs1 contrib]# ls -ltr
total 196
-rw-r--r--. 1 1107 1107 1131 May 11  2021 README
-rw-r--r--. 1 1107 1107 1461 May 11  2021 Makefile
-rw-r--r--. 1 1107 1107   85 May 11  2021 contrib-global.mk
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 unaccent
drwxrwxrwx. 2 1107 1107   74 May 11  2021 tcn
drwxrwxrwx. 2 1107 1107 4096 May 11  2021 sslinfo
drwxrwxrwx. 2 1107 1107   60 May 11  2021 pg_standby
drwxrwxrwx. 2 1107 1107 4096 May 11  2021 pg_prewarm
drwxrwxrwx. 5 1107 1107 4096 May 11  2021 hstore
drwxrwxrwx. 6 1107 1107 4096 May 11  2021 dblink
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 bool_plperl
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 adminpack
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 xml2
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 tsm_system_time
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 tsm_system_rows
drwxrwxrwx. 5 1107 1107 4096 May 11  2021 test_decoding
drwxrwxrwx. 5 1107 1107 4096 May 11  2021 tablefunc
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 sepgsql
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 pg_visibility
drwxrwxrwx. 5 1107 1107 4096 May 11  2021 pg_trgm
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 pgstattuple
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 pg_stat_statements
drwxrwxrwx. 2 1107 1107 4096 May 11  2021 pg_freespacemap
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 pgcrypto
drwxrwxrwx. 4 1107 1107   90 May 11  2021 passwordcheck
drwxrwxrwx. 3 1107 1107   67 May 11  2021 oid2name
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 ltree_plpython
drwxrwxrwx. 5 1107 1107 4096 May 11  2021 ltree
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 lo
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 jsonb_plpython
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 jsonb_plperl
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 isn
drwxrwxrwx. 6 1107 1107 4096 May 11  2021 intarray
drwxrwxrwx. 2 1107 1107   95 May 11  2021 intagg
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 hstore_plpython
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 hstore_plperl
drwxrwxrwx. 7 1107 1107 4096 May 11  2021 file_fdw
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 dict_xsyn
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 citext
drwxrwxrwx. 5 1107 1107 4096 May 11  2021 btree_gist
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 btree_gin
drwxrwxrwx. 5 1107 1107 4096 May 11  2021 bloom
drwxrwxrwx. 2 1107 1107   44 May 11  2021 auto_explain
drwxrwxrwx. 2 1107 1107   42 May 11  2021 auth_delay
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 amcheck
drwxrwxrwx. 3 1107 1107   67 May 11  2021 vacuumlo
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 uuid-ossp
drwxrwxrwx. 3 1107 1107   47 May 11  2021 start-scripts
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 postgres_fdw
drwxrwxrwx. 2 1107 1107 4096 May 11  2021 pgrowlocks
drwxrwxrwx. 2 1107 1107 4096 May 11  2021 pg_buffercache
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 pageinspect
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 fuzzystrmatch
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 earthdistance
drwxrwxrwx. 4 1107 1107 4096 May 11  2021 dict_int
drwxrwxrwx. 5 1107 1107 4096 May 11  2021 seg
drwxrwxrwx. 5 1107 1107 4096 May 11  2021 cube
drwxrwxrwx. 2 1107 1107 4096 Dec 23 00:54 spi
[root@pcs1 contrib]#
[root@pcs1 contrib]# make
make -C ../src/backend generated-headers
make[1]: Entering directory `/root/postgresql-13.3/src/backend'
make -C catalog distprep generated-header-symlinks
make[2]: Entering directory `/root/postgresql-13.3/src/backend/catalog'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/root/postgresql-13.3/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[2]: Entering directory `/root/postgresql-13.3/src/backend/utils'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/root/postgresql-13.3/src/backend/utils'
make[1]: Leaving directory `/root/postgresql-13.3/src/backend'
make -C adminpack all
make[1]: Entering directory `/root/postgresql-13.3/contrib/adminpack'
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I../../src/interfaces/libpq -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o adminpack.o adminpack.c
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -shared -o adminpack.so  adminpack.o -L../../src/port -L../../src/common    -Wl,--as-needed -Wl,-rpath,'/u01/app/postgres/13.3/lib',--enable-new-dtags
make[1]: Leaving directory `/root/postgresql-13.3/contrib/adminpack'
make -C amcheck all
make[1]: Entering directory `/root/postgresql-13.3/contrib/amcheck'
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o verify_nbtree.o verify_nbtree.c
..
..
..
make[1]: Entering directory `/root/postgresql-13.3/contrib/unaccent'
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o unaccent.o unaccent.c
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -shared -o unaccent.so  unaccent.o -L../../src/port -L../../src/common    -Wl,--as-needed -Wl,-rpath,'/u01/app/postgres/13.3/lib',--enable-new-dtags
make[1]: Leaving directory `/root/postgresql-13.3/contrib/unaccent'
make -C vacuumlo all
make[1]: Entering directory `/root/postgresql-13.3/contrib/vacuumlo'
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -I../../src/interfaces/libpq -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o vacuumlo.o vacuumlo.c
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2  vacuumlo.o -L../../src/common -lpgcommon -L../../src/port -lpgport -L../../src/interfaces/libpq -lpq -L../../src/port -L../../src/common   -Wl,--as-needed -Wl,-rpath,'/u01/app/postgres/13.3/lib',--enable-new-dtags   -lpgcommon -lpgport -lpthread -lz -lreadline -lrt -ldl -lm  -o vacuumlo
make[1]: Leaving directory `/root/postgresql-13.3/contrib/vacuumlo'
[root@pcs1 contrib]#


10. Install contrib module using make install command (optional)

[root@pcs1 contrib]# pwd
/root/postgresql-13.3/contrib
[root@pcs1 contrib]#
[root@pcs1 contrib]# make install
make -C ../src/backend generated-headers
make[1]: Entering directory `/root/postgresql-13.3/src/backend'
make -C catalog distprep generated-header-symlinks
make[2]: Entering directory `/root/postgresql-13.3/src/backend/catalog'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/root/postgresql-13.3/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[2]: Entering directory `/root/postgresql-13.3/src/backend/utils'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/root/postgresql-13.3/src/backend/utils'
make[1]: Leaving directory `/root/postgresql-13.3/src/backend'
make -C adminpack install
make[1]: Entering directory `/root/postgresql-13.3/contrib/adminpack'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  adminpack.so '/u01/app/postgres/13.3/lib/adminpack.so'
/usr/bin/install -c -m 644 ./adminpack.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./adminpack--1.0.sql ./adminpack--1.0--1.1.sql ./adminpack--1.1--2.0.sql ./adminpack--2.0--2.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/adminpack'
make -C amcheck install
make[1]: Entering directory `/root/postgresql-13.3/contrib/amcheck'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  amcheck.so '/u01/app/postgres/13.3/lib/amcheck.so'
/usr/bin/install -c -m 644 ./amcheck.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./amcheck--1.1--1.2.sql ./amcheck--1.0--1.1.sql ./amcheck--1.0.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/amcheck'
make -C auth_delay install
make[1]: Entering directory `/root/postgresql-13.3/contrib/auth_delay'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  auth_delay.so '/u01/app/postgres/13.3/lib/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/auth_delay'
make -C auto_explain install
make[1]: Entering directory `/root/postgresql-13.3/contrib/auto_explain'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  auto_explain.so '/u01/app/postgres/13.3/lib/auto_explain.so'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/auto_explain'
make -C bloom install
make[1]: Entering directory `/root/postgresql-13.3/contrib/bloom'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  bloom.so '/u01/app/postgres/13.3/lib/bloom.so'
/usr/bin/install -c -m 644 ./bloom.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./bloom--1.0.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/bloom'
make -C btree_gin install
make[1]: Entering directory `/root/postgresql-13.3/contrib/btree_gin'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  btree_gin.so '/u01/app/postgres/13.3/lib/btree_gin.so'
/usr/bin/install -c -m 644 ./btree_gin.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./btree_gin--1.0.sql ./btree_gin--1.0--1.1.sql ./btree_gin--1.1--1.2.sql ./btree_gin--1.2--1.3.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/btree_gin'
make -C btree_gist install
make[1]: Entering directory `/root/postgresql-13.3/contrib/btree_gist'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  btree_gist.so '/u01/app/postgres/13.3/lib/btree_gist.so'
/usr/bin/install -c -m 644 ./btree_gist.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./btree_gist--1.0--1.1.sql ./btree_gist--1.1--1.2.sql ./btree_gist--1.2.sql ./btree_gist--1.2--1.3.sql ./btree_gist--1.3--1.4.sql ./btree_gist--1.4--1.5.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/btree_gist'
make -C citext install
make[1]: Entering directory `/root/postgresql-13.3/contrib/citext'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 644 ./citext.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./citext--1.4.sql ./citext--1.5--1.6.sql ./citext--1.4--1.5.sql ./citext--1.3--1.4.sql ./citext--1.2--1.3.sql ./citext--1.1--1.2.sql ./citext--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 755  citext.so '/u01/app/postgres/13.3/lib/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/citext'
make -C cube install
make[1]: Entering directory `/root/postgresql-13.3/contrib/cube'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  cube.so '/u01/app/postgres/13.3/lib/cube.so'
/usr/bin/install -c -m 644 ./cube.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./cube--1.2.sql ./cube--1.2--1.3.sql ./cube--1.3--1.4.sql ./cube--1.1--1.2.sql ./cube--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/include/server/extension/cube/'
/usr/bin/install -c -m 644   ./cubedata.h '/u01/app/postgres/13.3/include/server/extension/cube/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/cube'
make -C dblink install
make[1]: Entering directory `/root/postgresql-13.3/contrib/dblink'
make -C ../../src/interfaces/libpq all
make[2]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[3]: Entering directory `/root/postgresql-13.3/src/port'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[3]: Entering directory `/root/postgresql-13.3/src/common'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/common'
make[2]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  dblink.so '/u01/app/postgres/13.3/lib/dblink.so'
/usr/bin/install -c -m 644 ./dblink.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./dblink--1.2.sql ./dblink--1.1--1.2.sql ./dblink--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/dblink'
make -C dict_int install
make[1]: Entering directory `/root/postgresql-13.3/contrib/dict_int'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  dict_int.so '/u01/app/postgres/13.3/lib/dict_int.so'
/usr/bin/install -c -m 644 ./dict_int.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./dict_int--1.0.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/dict_int'
make -C dict_xsyn install
make[1]: Entering directory `/root/postgresql-13.3/contrib/dict_xsyn'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/tsearch_data'
/usr/bin/install -c -m 755  dict_xsyn.so '/u01/app/postgres/13.3/lib/dict_xsyn.so'
/usr/bin/install -c -m 644 ./dict_xsyn.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./dict_xsyn--1.0.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./xsyn_sample.rules '/u01/app/postgres/13.3/share/tsearch_data/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/dict_xsyn'
make -C earthdistance install
make[1]: Entering directory `/root/postgresql-13.3/contrib/earthdistance'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 644 ./earthdistance.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./earthdistance--1.1.sql ./earthdistance--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 755  earthdistance.so '/u01/app/postgres/13.3/lib/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/earthdistance'
make -C file_fdw install
make[1]: Entering directory `/root/postgresql-13.3/contrib/file_fdw'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 644 ./file_fdw.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./file_fdw--1.0.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 755  file_fdw.so '/u01/app/postgres/13.3/lib/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/file_fdw'
make -C fuzzystrmatch install
make[1]: Entering directory `/root/postgresql-13.3/contrib/fuzzystrmatch'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  fuzzystrmatch.so '/u01/app/postgres/13.3/lib/fuzzystrmatch.so'
/usr/bin/install -c -m 644 ./fuzzystrmatch.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./fuzzystrmatch--1.1.sql ./fuzzystrmatch--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/fuzzystrmatch'
make -C hstore install
make[1]: Entering directory `/root/postgresql-13.3/contrib/hstore'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  hstore.so '/u01/app/postgres/13.3/lib/hstore.so'
/usr/bin/install -c -m 644 ./hstore.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./hstore--1.4.sql ./hstore--1.6--1.7.sql ./hstore--1.5--1.6.sql ./hstore--1.4--1.5.sql ./hstore--1.3--1.4.sql ./hstore--1.2--1.3.sql ./hstore--1.1--1.2.sql ./hstore--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/include/server/extension/hstore/'
/usr/bin/install -c -m 644   ./hstore.h '/u01/app/postgres/13.3/include/server/extension/hstore/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/hstore'
make -C intagg install
make[1]: Entering directory `/root/postgresql-13.3/contrib/intagg'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 644 ./intagg.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./intagg--1.1.sql ./intagg--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/intagg'
make -C intarray install
make[1]: Entering directory `/root/postgresql-13.3/contrib/intarray'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  _int.so '/u01/app/postgres/13.3/lib/_int.so'
/usr/bin/install -c -m 644 ./intarray.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./intarray--1.2--1.3.sql ./intarray--1.2.sql ./intarray--1.1--1.2.sql ./intarray--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/intarray'
make -C isn install
make[1]: Entering directory `/root/postgresql-13.3/contrib/isn'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 644 ./isn.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./isn--1.1.sql ./isn--1.1--1.2.sql ./isn--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 755  isn.so '/u01/app/postgres/13.3/lib/'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/include/server/extension/isn/'
/usr/bin/install -c -m 644  ./isn.h '/u01/app/postgres/13.3/include/server/extension/isn/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/isn'
make -C lo install
make[1]: Entering directory `/root/postgresql-13.3/contrib/lo'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 644 ./lo.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./lo--1.1.sql ./lo--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 755  lo.so '/u01/app/postgres/13.3/lib/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/lo'
make -C ltree install
make[1]: Entering directory `/root/postgresql-13.3/contrib/ltree'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  ltree.so '/u01/app/postgres/13.3/lib/ltree.so'
/usr/bin/install -c -m 644 ./ltree.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./ltree--1.1--1.2.sql ./ltree--1.1.sql ./ltree--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/include/server/extension/ltree/'
/usr/bin/install -c -m 644   ./ltree.h '/u01/app/postgres/13.3/include/server/extension/ltree/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/ltree'
make -C oid2name install
make[1]: Entering directory `/root/postgresql-13.3/contrib/oid2name'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  oid2name '/u01/app/postgres/13.3/bin'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/oid2name'
make -C pageinspect install
make[1]: Entering directory `/root/postgresql-13.3/contrib/pageinspect'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  pageinspect.so '/u01/app/postgres/13.3/lib/pageinspect.so'
/usr/bin/install -c -m 644 ./pageinspect.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./pageinspect--1.7--1.8.sql ./pageinspect--1.6--1.7.sql ./pageinspect--1.5.sql ./pageinspect--1.5--1.6.sql ./pageinspect--1.4--1.5.sql ./pageinspect--1.3--1.4.sql ./pageinspect--1.2--1.3.sql ./pageinspect--1.1--1.2.sql ./pageinspect--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/pageinspect'
make -C passwordcheck install
make[1]: Entering directory `/root/postgresql-13.3/contrib/passwordcheck'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  passwordcheck.so '/u01/app/postgres/13.3/lib/passwordcheck.so'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/passwordcheck'
make -C pg_buffercache install
make[1]: Entering directory `/root/postgresql-13.3/contrib/pg_buffercache'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  pg_buffercache.so '/u01/app/postgres/13.3/lib/pg_buffercache.so'
/usr/bin/install -c -m 644 ./pg_buffercache.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./pg_buffercache--1.2.sql ./pg_buffercache--1.2--1.3.sql ./pg_buffercache--1.1--1.2.sql ./pg_buffercache--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/pg_buffercache'
make -C pg_freespacemap install
make[1]: Entering directory `/root/postgresql-13.3/contrib/pg_freespacemap'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  pg_freespacemap.so '/u01/app/postgres/13.3/lib/pg_freespacemap.so'
/usr/bin/install -c -m 644 ./pg_freespacemap.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./pg_freespacemap--1.1.sql ./pg_freespacemap--1.1--1.2.sql ./pg_freespacemap--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/pg_freespacemap'
make -C pg_prewarm install
make[1]: Entering directory `/root/postgresql-13.3/contrib/pg_prewarm'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  pg_prewarm.so '/u01/app/postgres/13.3/lib/pg_prewarm.so'
/usr/bin/install -c -m 644 ./pg_prewarm.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./pg_prewarm--1.1--1.2.sql ./pg_prewarm--1.1.sql ./pg_prewarm--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/pg_prewarm'
make -C pg_standby install
make[1]: Entering directory `/root/postgresql-13.3/contrib/pg_standby'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  pg_standby '/u01/app/postgres/13.3/bin'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/pg_standby'
make -C pg_stat_statements install
make[1]: Entering directory `/root/postgresql-13.3/contrib/pg_stat_statements'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  pg_stat_statements.so '/u01/app/postgres/13.3/lib/pg_stat_statements.so'
/usr/bin/install -c -m 644 ./pg_stat_statements.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./pg_stat_statements--1.4.sql ./pg_stat_statements--1.7--1.8.sql ./pg_stat_statements--1.6--1.7.sql ./pg_stat_statements--1.5--1.6.sql ./pg_stat_statements--1.4--1.5.sql ./pg_stat_statements--1.3--1.4.sql ./pg_stat_statements--1.2--1.3.sql ./pg_stat_statements--1.1--1.2.sql ./pg_stat_statements--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/pg_stat_statements'
make -C pg_trgm install
make[1]: Entering directory `/root/postgresql-13.3/contrib/pg_trgm'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  pg_trgm.so '/u01/app/postgres/13.3/lib/pg_trgm.so'
/usr/bin/install -c -m 644 ./pg_trgm.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./pg_trgm--1.4--1.5.sql ./pg_trgm--1.3--1.4.sql ./pg_trgm--1.3.sql ./pg_trgm--1.2--1.3.sql ./pg_trgm--1.1--1.2.sql ./pg_trgm--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/pg_trgm'
make -C pgcrypto install
make[1]: Entering directory `/root/postgresql-13.3/contrib/pgcrypto'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  pgcrypto.so '/u01/app/postgres/13.3/lib/pgcrypto.so'
/usr/bin/install -c -m 644 ./pgcrypto.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./pgcrypto--1.3.sql ./pgcrypto--1.2--1.3.sql ./pgcrypto--1.1--1.2.sql ./pgcrypto--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/pgcrypto'
make -C pgrowlocks install
make[1]: Entering directory `/root/postgresql-13.3/contrib/pgrowlocks'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  pgrowlocks.so '/u01/app/postgres/13.3/lib/pgrowlocks.so'
/usr/bin/install -c -m 644 ./pgrowlocks.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./pgrowlocks--1.2.sql ./pgrowlocks--1.1--1.2.sql ./pgrowlocks--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/pgrowlocks'
make -C pgstattuple install
make[1]: Entering directory `/root/postgresql-13.3/contrib/pgstattuple'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  pgstattuple.so '/u01/app/postgres/13.3/lib/pgstattuple.so'
/usr/bin/install -c -m 644 ./pgstattuple.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./pgstattuple--1.4.sql ./pgstattuple--1.4--1.5.sql ./pgstattuple--1.3--1.4.sql ./pgstattuple--1.2--1.3.sql ./pgstattuple--1.1--1.2.sql ./pgstattuple--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/pgstattuple'
make -C pg_visibility install
make[1]: Entering directory `/root/postgresql-13.3/contrib/pg_visibility'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  pg_visibility.so '/u01/app/postgres/13.3/lib/pg_visibility.so'
/usr/bin/install -c -m 644 ./pg_visibility.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./pg_visibility--1.1.sql ./pg_visibility--1.1--1.2.sql ./pg_visibility--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/pg_visibility'
make -C postgres_fdw install
make[1]: Entering directory `/root/postgresql-13.3/contrib/postgres_fdw'
make -C ../../src/interfaces/libpq all
make[2]: Entering directory `/root/postgresql-13.3/src/interfaces/libpq'
make -C ../../../src/port all
make[3]: Entering directory `/root/postgresql-13.3/src/port'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/port'
make -C ../../../src/common all
make[3]: Entering directory `/root/postgresql-13.3/src/common'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/postgresql-13.3/src/common'
make[2]: Leaving directory `/root/postgresql-13.3/src/interfaces/libpq'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  postgres_fdw.so '/u01/app/postgres/13.3/lib/postgres_fdw.so'
/usr/bin/install -c -m 644 ./postgres_fdw.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./postgres_fdw--1.0.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/postgres_fdw'
make -C seg install
make[1]: Entering directory `/root/postgresql-13.3/contrib/seg'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  seg.so '/u01/app/postgres/13.3/lib/seg.so'
/usr/bin/install -c -m 644 ./seg.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./seg--1.1.sql ./seg--1.1--1.2.sql ./seg--1.2--1.3.sql ./seg--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/include/server/extension/seg/'
/usr/bin/install -c -m 644   ./segdata.h '/u01/app/postgres/13.3/include/server/extension/seg/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/seg'
make -C spi install
make[1]: Entering directory `/root/postgresql-13.3/contrib/spi'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/doc//extension'
/usr/bin/install -c -m 644 ./autoinc.control ./insert_username.control ./moddatetime.control ./refint.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./autoinc--1.0.sql ./insert_username--1.0.sql ./moddatetime--1.0.sql ./refint--1.0.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 755  autoinc.so insert_username.so moddatetime.so refint.so '/u01/app/postgres/13.3/lib/'
/usr/bin/install -c -m 644 ./autoinc.example ./insert_username.example ./moddatetime.example ./refint.example '/u01/app/postgres/13.3/share/doc//extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/spi'
make -C tablefunc install
make[1]: Entering directory `/root/postgresql-13.3/contrib/tablefunc'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 644 ./tablefunc.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./tablefunc--1.0.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 755  tablefunc.so '/u01/app/postgres/13.3/lib/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/tablefunc'
make -C tcn install
make[1]: Entering directory `/root/postgresql-13.3/contrib/tcn'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 644 ./tcn.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./tcn--1.0.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 755  tcn.so '/u01/app/postgres/13.3/lib/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/tcn'
make -C test_decoding install
make[1]: Entering directory `/root/postgresql-13.3/contrib/test_decoding'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/install -c -m 755  test_decoding.so '/u01/app/postgres/13.3/lib/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/test_decoding'
make -C tsm_system_rows install
make[1]: Entering directory `/root/postgresql-13.3/contrib/tsm_system_rows'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  tsm_system_rows.so '/u01/app/postgres/13.3/lib/tsm_system_rows.so'
/usr/bin/install -c -m 644 ./tsm_system_rows.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./tsm_system_rows--1.0.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/tsm_system_rows'
make -C tsm_system_time install
make[1]: Entering directory `/root/postgresql-13.3/contrib/tsm_system_time'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/install -c -m 755  tsm_system_time.so '/u01/app/postgres/13.3/lib/tsm_system_time.so'
/usr/bin/install -c -m 644 ./tsm_system_time.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./tsm_system_time--1.0.sql  '/u01/app/postgres/13.3/share/extension/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/tsm_system_time'
make -C unaccent install
make[1]: Entering directory `/root/postgresql-13.3/contrib/unaccent'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/lib'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/extension'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/share/tsearch_data'
/usr/bin/install -c -m 755  unaccent.so '/u01/app/postgres/13.3/lib/unaccent.so'
/usr/bin/install -c -m 644 ./unaccent.control '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./unaccent--1.1.sql ./unaccent--1.0--1.1.sql  '/u01/app/postgres/13.3/share/extension/'
/usr/bin/install -c -m 644 ./unaccent.rules '/u01/app/postgres/13.3/share/tsearch_data/'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/unaccent'
make -C vacuumlo install
make[1]: Entering directory `/root/postgresql-13.3/contrib/vacuumlo'
/usr/bin/mkdir -p '/u01/app/postgres/13.3/bin'
/usr/bin/install -c  vacuumlo '/u01/app/postgres/13.3/bin'
make[1]: Leaving directory `/root/postgresql-13.3/contrib/vacuumlo'
[root@pcs1 contrib]#


11. Validation

[root@pcs1 ~]# cd /u01/app/postgres/13.3/bin/
[root@pcs1 bin]# ls -ltr
total 12760
-rwxr-xr-x. 1 root root 8289176 Dec 23 01:01 postgres
lrwxrwxrwx. 1 root root       8 Dec 23 01:01 postmaster -> postgres
-rwxr-xr-x. 1 root root  972200 Dec 23 01:01 ecpg
-rwxr-xr-x. 1 root root  142688 Dec 23 01:01 initdb
-rwxr-xr-x. 1 root root   48696 Dec 23 01:01 pg_archivecleanup
-rwxr-xr-x. 1 root root  131440 Dec 23 01:01 pg_basebackup
-rwxr-xr-x. 1 root root   93464 Dec 23 01:01 pg_receivewal
-rwxr-xr-x. 1 root root   94040 Dec 23 01:01 pg_recvlogical
-rwxr-xr-x. 1 root root   67240 Dec 23 01:01 pg_checksums
-rwxr-xr-x. 1 root root   43136 Dec 23 01:01 pg_config
-rwxr-xr-x. 1 root root   61632 Dec 23 01:01 pg_controldata
-rwxr-xr-x. 1 root root   77280 Dec 23 01:01 pg_ctl
-rwxr-xr-x. 1 root root  431760 Dec 23 01:01 pg_dump
-rwxr-xr-x. 1 root root  192456 Dec 23 01:01 pg_restore
-rwxr-xr-x. 1 root root  114352 Dec 23 01:01 pg_dumpall
-rwxr-xr-x. 1 root root   71696 Dec 23 01:01 pg_resetwal
-rwxr-xr-x. 1 root root  138560 Dec 23 01:01 pg_rewind
-rwxr-xr-x. 1 root root   49424 Dec 23 01:01 pg_test_fsync
-rwxr-xr-x. 1 root root   43504 Dec 23 01:01 pg_test_timing
-rwxr-xr-x. 1 root root  154184 Dec 23 01:01 pg_upgrade
-rwxr-xr-x. 1 root root  109792 Dec 23 01:01 pg_verifybackup
-rwxr-xr-x. 1 root root  108760 Dec 23 01:01 pg_waldump
-rwxr-xr-x. 1 root root  174008 Dec 23 01:01 pgbench
-rwxr-xr-x. 1 root root  630160 Dec 23 01:01 psql
-rwxr-xr-x. 1 root root   82840 Dec 23 01:01 createdb
-rwxr-xr-x. 1 root root   73680 Dec 23 01:01 dropdb
-rwxr-xr-x. 1 root root   79088 Dec 23 01:01 createuser
-rwxr-xr-x. 1 root root   73616 Dec 23 01:01 dropuser
-rwxr-xr-x. 1 root root   78584 Dec 23 01:01 clusterdb
-rwxr-xr-x. 1 root root   87648 Dec 23 01:01 vacuumdb
-rwxr-xr-x. 1 root root   83432 Dec 23 01:01 reindexdb
-rwxr-xr-x. 1 root root   73664 Dec 23 01:01 pg_isready
-rwxr-xr-x. 1 root root   48776 Dec 23 01:15 oid2name
-rwxr-xr-x. 1 root root   43720 Dec 23 01:15 pg_standby
-rwxr-xr-x. 1 root root   48488 Dec 23 01:15 vacuumlo
[root@pcs1 bin]# ./pg_config
BINDIR = /u01/app/postgres/13.3/bin
DOCDIR = /u01/app/postgres/13.3/share/doc
HTMLDIR = /u01/app/postgres/13.3/share/doc
INCLUDEDIR = /u01/app/postgres/13.3/include
PKGINCLUDEDIR = /u01/app/postgres/13.3/include
INCLUDEDIR-SERVER = /u01/app/postgres/13.3/include/server
LIBDIR = /u01/app/postgres/13.3/lib
PKGLIBDIR = /u01/app/postgres/13.3/lib
LOCALEDIR = /u01/app/postgres/13.3/share/locale
MANDIR = /u01/app/postgres/13.3/share/man
SHAREDIR = /u01/app/postgres/13.3/share
SYSCONFDIR = /u01/app/postgres/13.3/etc
PGXS = /u01/app/postgres/13.3/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE =  '--prefix=/u01/app/postgres/13.3' '--with-pgport=5432'
CC = gcc -std=gnu99
CPPFLAGS = -D_GNU_SOURCE
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2
CFLAGS_SL = -fPIC
LDFLAGS = -Wl,--as-needed -Wl,-rpath,'/u01/app/postgres/13.3/lib',--enable-new-dtags
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgcommon -lpgport -lpthread -lz -lreadline -lrt -ldl -lm
VERSION = PostgreSQL 13.3
[root@pcs1 bin]#

pg_config utility working fine.


12. Change binary owner to postgres

[root@pcs1 ~]# chown -R postgres:postgres /u02/app/psql/13.3/DATA
[root@pcs1 ~]# chown -R postgres:postgres /u01/app/postgres


13. Initialize postgreSQL data directory using postgres user

[root@pcs1 13.3]# su - postgres
[postgres@pcs1 ~]$
[postgres@pcs1 ~]$
[postgres@pcs1 ~]$ ps -ef | grep postgres
root      3098  1810  0 01:59 pts/1    00:00:00 su - postgres
postgres  3101  3098  0 01:59 pts/1    00:00:00 -bash
postgres  3183  3101  0 01:59 pts/1    00:00:00 ps -ef
postgres  3184  3101  0 01:59 pts/1    00:00:00 grep --color=auto postgres
[postgres@pcs1 ~]$
[postgres@pcs1 ~]$ /u01/app/postgres/13.3/bin/initdb -D /u02/app/psql/13.3/DATA
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /u02/app/psql/13.3/DATA ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Singapore
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /u01/app/postgres/13.3/bin/pg_ctl -D /u02/app/psql/13.3/DATA -l logfile start

[postgres@pcs1 ~]$


14. Validate the postgreSQL data directory

[postgres@pcs1 postgres]$ cd /u02/app/psql/13.3/DATA/
[postgres@pcs1 DATA]$ ls -ltr
total 124
drwx------. 2 postgres postgres  4096 Dec 23 01:59 pg_twophase
drwx------. 2 postgres postgres  4096 Dec 23 01:59 pg_snapshots
drwx------. 2 postgres postgres  4096 Dec 23 01:59 pg_serial
drwx------. 2 postgres postgres  4096 Dec 23 01:59 pg_replslot
drwx------. 2 postgres postgres  4096 Dec 23 01:59 pg_notify
drwx------. 4 postgres postgres  4096 Dec 23 01:59 pg_multixact
drwx------. 2 postgres postgres  4096 Dec 23 01:59 pg_dynshmem
drwx------. 2 postgres postgres  4096 Dec 23 01:59 pg_commit_ts
-rw-------. 1 postgres postgres     3 Dec 23 01:59 PG_VERSION
drwx------. 2 postgres postgres  4096 Dec 23 01:59 pg_tblspc
drwx------. 2 postgres postgres  4096 Dec 23 01:59 pg_stat
-rw-------. 1 postgres postgres 28025 Dec 23 01:59 postgresql.conf
-rw-------. 1 postgres postgres    88 Dec 23 01:59 postgresql.auto.conf
-rw-------. 1 postgres postgres  4760 Dec 23 01:59 pg_hba.conf
-rw-------. 1 postgres postgres  1636 Dec 23 01:59 pg_ident.conf
drwx------. 2 postgres postgres  4096 Dec 23 01:59 pg_xact
drwx------. 3 postgres postgres  4096 Dec 23 01:59 pg_wal
drwx------. 2 postgres postgres  4096 Dec 23 01:59 pg_subtrans
drwx------. 2 postgres postgres  4096 Dec 23 01:59 global
drwx------. 5 postgres postgres  4096 Dec 23 01:59 base
-rw-------. 1 postgres postgres    67 Dec 23 02:05 postmaster.opts
-rw-------. 1 postgres postgres    89 Dec 23 02:05 postmaster.pid
drwx------. 4 postgres postgres  4096 Dec 23 02:10 pg_logical
drwx------. 2 postgres postgres  4096 Dec 23 03:21 pg_stat_tmp
[postgres@pcs1 DATA]$


15. Start postgreSQL database as postgres user

[postgres@pcs1 ~]$ /u01/app/postgres/13.3/bin/pg_ctl -D /u02/app/psql/13.3/DATA status
pg_ctl: no server running
[postgres@pcs1 ~]$
[postgres@pcs1 ~]$ /u01/app/postgres/13.3/bin/pg_ctl -D /u02/app/psql/13.3/DATA start
waiting for server to start....2021-12-23 02:05:49.529 +08 [3695] LOG:  starting PostgreSQL 13.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44.0.3), 64-bit
2021-12-23 02:05:49.532 +08 [3695] LOG:  listening on IPv6 address "::1", port 5432
2021-12-23 02:05:49.532 +08 [3695] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2021-12-23 02:05:49.537 +08 [3695] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2021-12-23 02:05:49.543 +08 [3696] LOG:  database system was shut down at 2021-12-23 01:59:40 +08
2021-12-23 02:05:49.548 +08 [3695] LOG:  database system is ready to accept connections
 done
server started
[postgres@pcs1 ~]$
[postgres@pcs1 ~]$ /u01/app/postgres/13.3/bin/pg_ctl -D /u02/app/psql/13.3/DATA status
pg_ctl: server is running (PID: 3695)
/u01/app/postgres/13.3/bin/postgres "-D" "/u02/app/psql/13.3/DATA"
[postgres@pcs1 ~]$

[postgres@pcs1 ~]$ ps -ef | grep postgres
root      3098  1810  0 01:59 pts/1    00:00:00 su - postgres
postgres  3101  3098  0 01:59 pts/1    00:00:00 -bash
postgres  3695     1  0 02:05 ?        00:00:00 /u01/app/postgres/13.3/bin/postgres -D /u02/app/psql/13.3/DATA
postgres  3697  3695  0 02:05 ?        00:00:00 postgres: checkpointer
postgres  3698  3695  0 02:05 ?        00:00:00 postgres: background writer
postgres  3699  3695  0 02:05 ?        00:00:00 postgres: walwriter
postgres  3700  3695  0 02:05 ?        00:00:00 postgres: autovacuum launcher
postgres  3701  3695  0 02:05 ?        00:00:00 postgres: stats collector
postgres  3702  3695  0 02:05 ?        00:00:00 postgres: logical replication launcher
postgres  3768  3101  0 02:06 pts/1    00:00:00 ps -ef
postgres  3769  3101  0 02:06 pts/1    00:00:00 grep --color=auto postgres
[postgres@pcs1 ~]$


16. Setting the postgres User Environment Variables

[postgres@pcs1 ~]$ psql
bash: psql: command not found...
[postgres@pcs1 ~]$ 

cat pg.env

export LD_LIBRARY_PATH=/u01/app/postgres/13.3/lib:$LD_LIBRARY_PATH
export PATH=/u01/app/postgres/13.3/bin:$PATH

[postgres@pcs1 ~]$ . pg.env
[postgres@pcs1 ~]$ 
[postgres@pcs1 ~]$ psql
psql (13.3)
Type "help" for help.

postgres=#


17. Create postgreSQL DB and test the installation

[postgres@pcs1 ~]$ psql
psql (13.3)
Type "help" for help.

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)

postgres=#
postgres=# create database test;
CREATE DATABASE
postgres=#
postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)

postgres=#

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
WhatsApp : +
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

PostgreSQL DBA – How to Create Database in PostgreSQL?

PostgreSQL DBA – How to Create Database in PostgreSQL?

Table of Contents
___________________________________________________________________________________________________

0. How to Find Create Database Syntax in PostgreSQL?
1. How to List All Databases in PostgreSQL using psql?
2. How To Create New Database in PostgreSQL using psql?
3. How To Create New Database With Owner in PostgreSQL using psql?
4. How To Create New Database With Tablespace in PostgreSQL using psql?
5. How To Create New Database With Encoding in PostgreSQL using psql?
6. How To Create New Database With Template in PostgreSQL using psql?
7. How to Create New Database With Binary Owner in PostgreSQL using Command Line?
8. How to Connect to Database in PostgreSQL using psql?
9. How to Find the Version of Database in PostgreSQL?
10. How to Exit from PostgreSQL?
___________________________________________________________________________________________________


0. How to Find Create Database Syntax in PostgreSQL?

[postgres@rac1 ~]$ psql
psql (13.2)
Type "help" for help.

postgres=# \h CREATE DATABASE
Command:     CREATE DATABASE
Description: create a new database
Syntax:
CREATE DATABASE name
    [ [ WITH ] [ OWNER [=] user_name ]
           [ TEMPLATE [=] template ]
           [ ENCODING [=] encoding ]
           [ LOCALE [=] locale ]
           [ LC_COLLATE [=] lc_collate ]
           [ LC_CTYPE [=] lc_ctype ]
           [ TABLESPACE [=] tablespace_name ]
           [ ALLOW_CONNECTIONS [=] allowconn ]
           [ CONNECTION LIMIT [=] connlimit ]
           [ IS_TEMPLATE [=] istemplate ] ]

URL: https://www.postgresql.org/docs/13/sql-createdatabase.html

postgres=#


1. How to List All Databases in PostgreSQL using psql?

postgres=# \l+
                                                                    List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   |  Size   | Tablespace |                Description
-----------+----------+----------+-------------+-------------+-----------------------+---------+------------+--------------------------------------------
 orcl      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 8117 kB | pg_default |
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 8117 kB | pg_default | default administrative connection database
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +| 7969 kB | pg_default | unmodifiable empty database
           |          |          |             |             | postgres=CTc/postgres |         |            |
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +| 7969 kB | pg_default | default template for new databases
           |          |          |             |             | postgres=CTc/postgres |         |            |
(4 rows)

postgres=#

postgres=# select oid,datname from pg_database;
  oid  |  datname
-------+-----------
 14172 | postgres
 16384 | orcl
     1 | template1
 14171 | template0
(4 rows)

postgres=#


select * from pg_database;


2. How To Create New database in PostgreSQL using psql?

postgres=# create database test;
CREATE DATABASE
postgres=#
postgres=# SELECT (pg_stat_file('base/'||oid ||'/PG_VERSION')).modification, datname FROM pg_database where datname='test';
      modification      | datname
------------------------+---------
 2021-03-15 21:30:27+08 | test <----
(1 row)

postgres=#


3. How To Create New database With Owner in PostgreSQL using psql?

postgres=# create user vishnu with password 'vishnu';
CREATE ROLE
postgres=# CREATE DATABASE test2 OWNER vishnu;
CREATE DATABASE
postgres=#
postgres=# \l+ test2
                                               List of databases
 Name  | Owner  | Encoding |   Collate   |    Ctype    | Access privileges |  Size   | Tablespace | Description
-------+--------+----------+-------------+-------------+-------------------+---------+------------+-------------
 test2 | vishnu | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                   | 7969 kB | pg_default |
(1 row)

postgres=#


4. How To Create New database With Tablespace in PostgreSQL using psql?

[root@rac1 ~]# mkdir -p /u01/postgres/data/test3_tbs
[root@rac1 ~]# chown -R postgres:postgres /u01/postgres
[root@rac1 ~]# chmod -R 750 /u01/postgres

postgres=# CREATE TABLESPACE test3_tbs LOCATION '/u01/postgres/data/test3_tbs';
CREATE TABLESPACE
postgres=#

postgres=# CREATE DATABASE test3 TABLESPACE test3_tbs;
CREATE DATABASE
postgres=# select datname from pg_database where datname='test3';
 datname
---------
 test3 <----
(1 row)

postgres=#


5. How To Create New database With Encoding in PostgreSQL using psql?

postgres=# CREATE DATABASE test4 ENCODING 'UTF8';
CREATE DATABASE
postgres=#
postgres=# \l+ test4
                                                List of databases
 Name  |  Owner   | Encoding |   Collate   |    Ctype    | Access privileges |  Size   | Tablespace | Description
-------+----------+----------+-------------+-------------+-------------------+---------+------------+-------------
 test4 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                   | 7969 kB | pg_default |
(1 row)

postgres=#


6. How To Create New database With Template in PostgreSQL using psql?

postgres=# \l+ template1
                                                                List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   |  Size   | Tablespace |            Description
-----------+----------+----------+-------------+-------------+-----------------------+---------+------------+------------------------------------
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +| 7969 kB | pg_default | default template for new databases
           |          |          |             |             | postgres=CTc/postgres |         |            |
(1 row)

postgres=#

postgres=# CREATE DATABASE test5 TEMPLATE template1;
CREATE DATABASE
postgres=#
postgres=# \l+ test5
                                                List of databases
 Name  |  Owner   | Encoding |   Collate   |    Ctype    | Access privileges |  Size   | Tablespace | Description
-------+----------+----------+-------------+-------------+-------------------+---------+------------+-------------
 test5 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                   | 7969 kB | pg_default |
(1 row)

postgres=#


7. How to Create New Database With Binary Owner in PostgreSQL using Command Line?

[postgres@rac1 ~]$ id
uid=26(postgres) gid=26(postgres) groups=26(postgres) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[postgres@rac1 ~]$
[postgres@rac1 ~]$ which createdb
/bin/createdb
[postgres@rac1 ~]$
[postgres@rac1 ~]$ createdb test6
[postgres@rac1 ~]$

postgres=# \l+ test6
                                                List of databases
 Name  |  Owner   | Encoding |   Collate   |    Ctype    | Access privileges |  Size   | Tablespace | Description
-------+----------+----------+-------------+-------------+-------------------+---------+------------+-------------
 test6 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                   | 7969 kB | pg_default |
(1 row)

postgres=#


8. How to Connect to Database in PostgreSQL using psql?

[postgres@rac1 ~]$ id
uid=26(postgres) gid=26(postgres) groups=26(postgres) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[postgres@rac1 ~]$ psql
psql (13.2)
Type "help" for help.

postgres=#
postgres=#  SELECT current_database();
 current_database
------------------
 postgres <-----
(1 row)

postgres=#
postgres=# \c test2    <---- to connect to selective database
You are now connected to database "test2" as user "postgres".
test2=#
test2=# SELECT current_database();
 current_database
------------------
 test2 <----
(1 row)

test2=#

--- OR ---

[postgres@rac1 ~]$ psql orcl
psql (13.2)
Type "help" for help.

orcl=#  <---- Now we connected to database "orcl"


9. How to Find the Version of Database in PostgreSQL using psql?

test2=# select version();
                                                 version
---------------------------------------------------------------------------------------------------------
 PostgreSQL 13.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)

test2=#

-- OR --

[postgres@rac1 ~]$ psql
psql (13.2)  <-----
Type "help" for help.

postgres=#


10. How to Exit from PostgreSQL?

test2=# \q  <---- To quit from Postgres prompt.
[postgres@rac1 ~]$

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/

PostgreSQL DBA – How to START/STOP PostgreSQL 13 ON RHEL 7

How to START/STOP PostgreSQL 13 ON RHEL 7

Table of Contents
___________________________________________________________________________________________________

0. Overview
1. How to check Postgres server status?
2. How to Stop Postgres server?
3. How to Start Postgres server?
4. How to Restart Postgres server?
5. How to Reload Postgres server?
___________________________________________________________________________________________________


0. Overview

As root user:

service postgresql-13.service status
service postgresql-13.service start
service postgresql-13.service restart
service postgresql-13.service reload
service postgresql-13.service stop

OR 

systemctl stop postgresql-13.service
systemctl start postgresql-13.service
systemctl restart postgresql-13.service
systemctl status postgresql-13.service
systemctl reload postgresql-13.service

As Postgres user use pg_ctl command

/usr/pgsql-13/bin/pg_ctl stop -D /var/lib/pgsql/13/data
/usr/pgsql-13/bin/pg_ctl start -D /var/lib/pgsql/13/data
/usr/pgsql-13/bin/pg_ctl restart -D /var/lib/pgsql/13/data
/usr/pgsql-13/bin/pg_ctl status -D /var/lib/pgsql/13/data
/usr/pgsql-13/bin/pg_ctl reload -D /var/lib/pgsql/13/data

Restart or reload is required when changes are made to the postgresql.conf file.

Reload simply reloads the configuration in-memory. Restart replaces the entire instance.


1. How to check Postgres server status?

[root@rac1 ~]# systemctl list-units|grep postgresql
  postgresql-13.service     loaded active running   PostgreSQL 13 database server
[root@rac1 ~]# 

---- OR -----

[root@rac1 ~]# service postgresql-13.service status
Redirecting to /bin/systemctl status postgresql-13.service
● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-03-15 17:57:05 +08; 53min ago
     Docs: https://www.postgresql.org/docs/13/static/
  Process: 969 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 991 (postmaster)
   CGroup: /system.slice/postgresql-13.service
           ├─ 991 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
           ├─1053 postgres: logger
           ├─1178 postgres: checkpointer
           ├─1179 postgres: background writer
           ├─1180 postgres: walwriter
           ├─1181 postgres: autovacuum launcher
           ├─1182 postgres: stats collector
           ├─1183 postgres: logical replication launcher
           └─2282 postgres: postgres postgres [local] idle

Mar 15 17:57:03 rac1.rajasekhar.com systemd[1]: Starting PostgreSQL 13 database server...
Mar 15 17:57:04 rac1.rajasekhar.com postmaster[991]: 2021-03-15 17:57:04.155 +08 [991] LOG:  redirecting log output to logging collector process
Mar 15 17:57:04 rac1.rajasekhar.com postmaster[991]: 2021-03-15 17:57:04.155 +08 [991] HINT:  Future log output will appear in directory "log".
Mar 15 17:57:05 rac1.rajasekhar.com systemd[1]: Started PostgreSQL 13 database server.
[root@rac1 ~]#

--- OR ---

[root@rac1 ~]# ps -ef | grep postgres
postgres   991     1  0 17:57 ?        00:00:00 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
postgres  1053   991  0 17:57 ?        00:00:00 postgres: logger
postgres  1178   991  0 17:57 ?        00:00:00 postgres: checkpointer
postgres  1179   991  0 17:57 ?        00:00:00 postgres: background writer
postgres  1180   991  0 17:57 ?        00:00:00 postgres: walwriter
postgres  1181   991  0 17:57 ?        00:00:00 postgres: autovacuum launcher
postgres  1182   991  0 17:57 ?        00:00:00 postgres: stats collector
postgres  1183   991  0 17:57 ?        00:00:00 postgres: logical replication launcher
root      2201  2143  0 17:58 pts/0    00:00:00 su - postgres
postgres  2202  2201  0 17:58 pts/0    00:00:00 -bash
postgres  2281  2202  0 17:58 pts/0    00:00:00 psql
postgres  2282   991  0 17:58 ?        00:00:00 postgres: postgres postgres [local] idle
root      5744  5275  0 18:55 pts/1    00:00:00 grep --color=auto postgres
[root@rac1 ~]#

OR

[postgres@rac1 ~]$ cd /usr/pgsql-13/bin/
[postgres@rac1 bin]$ ./pg_ctl status -D /var/lib/pgsql/13/data/
pg_ctl: server is running (PID: 991)
/usr/pgsql-13/bin/postgres "-D" "/var/lib/pgsql/13/data/"
[postgres@rac1 bin]$


2. How to Stop Postgres server?

[postgres@rac1 ~]$ cd /usr/pgsql-13/bin/
[postgres@rac1 bin]$ ./pg_ctl stop -D /var/lib/pgsql/13/data/
waiting for server to shut down.... done
server stopped
[postgres@rac1 bin]$

[root@rac1 ~]# ps -ef | grep postgres
root      6718  2143  0 19:07 pts/0    00:00:00 grep --color=auto postgres
[root@rac1 ~]#

--- OR ----

[root@rac1 ~]# service postgresql-13.service stop
Redirecting to /bin/systemctl stop postgresql-13.service
[root@rac1 ~]#
[root@rac1 ~]# service postgresql-13.service status
Redirecting to /bin/systemctl status postgresql-13.service
● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Mon 2021-03-15 19:07:03 +08; 5min ago
     Docs: https://www.postgresql.org/docs/13/static/
  Process: 991 ExecStart=/usr/pgsql-13/bin/postmaster -D ${PGDATA} (code=exited, status=0/SUCCESS)
  Process: 969 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 991 (code=exited, status=0/SUCCESS)

Mar 15 17:57:03 rac1.rajasekhar.com systemd[1]: Starting PostgreSQL 13 database server...
Mar 15 17:57:04 rac1.rajasekhar.com postmaster[991]: 2021-03-15 17:57:04.155 +08 [991] LOG:  redirecting log output to logging collector process
Mar 15 17:57:04 rac1.rajasekhar.com postmaster[991]: 2021-03-15 17:57:04.155 +08 [991] HINT:  Future log output will appear in directory "log".
Mar 15 17:57:05 rac1.rajasekhar.com systemd[1]: Started PostgreSQL 13 database server.
[root@rac1 ~]#


3. How to Start Postgres server?

[postgres@rac1 ~]$ cd /usr/pgsql-13/bin/
[postgres@rac1 bin]$ ./pg_ctl start -D /var/lib/pgsql/13/data/
waiting for server to start....2021-03-15 19:14:17.815 +08 [7443] LOG:  redirecting log output to logging collector process
2021-03-15 19:14:17.815 +08 [7443] HINT:  Future log output will appear in directory "log".
 done
server started
[postgres@rac1 bin]$

--- OR ---- 

[root@rac1 ~]# service postgresql-13.service start
Redirecting to /bin/systemctl start postgresql-13.service
[root@rac1 ~]#
[root@rac1 ~]# service postgresql-13.service status
Redirecting to /bin/systemctl status postgresql-13.service
● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-03-15 19:15:14 +08; 3s ago
     Docs: https://www.postgresql.org/docs/13/static/
  Process: 7523 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 7529 (postmaster)
   CGroup: /system.slice/postgresql-13.service
           ├─7529 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
           ├─7533 postgres: logger
           ├─7535 postgres: checkpointer
           ├─7536 postgres: background writer
           ├─7537 postgres: walwriter
           ├─7538 postgres: autovacuum launcher
           ├─7539 postgres: stats collector
           └─7540 postgres: logical replication launcher

Mar 15 19:15:14 rac1.rajasekhar.com systemd[1]: Starting PostgreSQL 13 database server...
Mar 15 19:15:14 rac1.rajasekhar.com postmaster[7529]: 2021-03-15 19:15:14.193 +08 [7529] LOG:  redirecting log output to logging collector process
Mar 15 19:15:14 rac1.rajasekhar.com postmaster[7529]: 2021-03-15 19:15:14.193 +08 [7529] HINT:  Future log output will appear in directory "log".
Mar 15 19:15:14 rac1.rajasekhar.com systemd[1]: Started PostgreSQL 13 database server.
[root@rac1 ~]#


4. How to Restart Postgres server?

-w, --wait             wait until operation completes (default)
  
[postgres@rac1 ~]$ cd /usr/pgsql-13/bin/
[postgres@rac1 bin]$ ./pg_ctl -w restart -D /var/lib/pgsql/13/data/
waiting for server to shut down.... done
server stopped
waiting for server to start....2021-03-15 19:22:58.920 +08 [8017] LOG:  redirecting log output to logging collector process
2021-03-15 19:22:58.920 +08 [8017] HINT:  Future log output will appear in directory "log".
 done
server started
[postgres@rac1 bin]$

--- OR ----

[root@rac1 ~]# service postgresql-13.service restart
Redirecting to /bin/systemctl restart postgresql-13.service
[root@rac1 ~]#
[root@rac1 ~]# service postgresql-13.service status
Redirecting to /bin/systemctl status postgresql-13.service
● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-03-15 19:52:26 +08; 3s ago
     Docs: https://www.postgresql.org/docs/13/static/
  Process: 10439 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 10445 (postmaster)
   CGroup: /system.slice/postgresql-13.service
           ├─10445 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
           ├─10449 postgres: logger
           ├─10451 postgres: checkpointer
           ├─10452 postgres: background writer
           ├─10453 postgres: walwriter
           ├─10454 postgres: autovacuum launcher
           ├─10455 postgres: stats collector
           └─10456 postgres: logical replication launcher

Mar 15 19:52:26 rac1.rajasekhar.com systemd[1]: Starting PostgreSQL 13 database server...
Mar 15 19:52:26 rac1.rajasekhar.com postmaster[10445]: 2021-03-15 19:52:26.856 +08 [10445] LOG:  redirecting log output to logging collector process
Mar 15 19:52:26 rac1.rajasekhar.com postmaster[10445]: 2021-03-15 19:52:26.856 +08 [10445] HINT:  Future log output will appear in directory "log".
Mar 15 19:52:26 rac1.rajasekhar.com systemd[1]: Started PostgreSQL 13 database server.
[root@rac1 ~]#


5. How to Reload Postgres server?

[postgres@rac1 bin]$ ./pg_ctl reload -D /var/lib/pgsql/13/data
server signaled
[postgres@rac1 bin]$

--- OR --- 

[root@rac1 ~]# service postgresql-13.service reload
Redirecting to /bin/systemctl reload postgresql-13.service
[root@rac1 ~]#
[root@rac1 ~]# service postgresql-13.service status
Redirecting to /bin/systemctl status postgresql-13.service
● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-03-15 19:52:26 +08; 11min ago
     Docs: https://www.postgresql.org/docs/13/static/
  Process: 11218 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
  Process: 10439 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 10445 (postmaster)
   CGroup: /system.slice/postgresql-13.service
           ├─10445 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
           ├─10449 postgres: logger
           ├─10451 postgres: checkpointer
           ├─10452 postgres: background writer
           ├─10453 postgres: walwriter
           ├─10454 postgres: autovacuum launcher
           ├─10455 postgres: stats collector
           └─10456 postgres: logical replication launcher

Mar 15 19:52:26 rac1.rajasekhar.com systemd[1]: Starting PostgreSQL 13 database server...
Mar 15 19:52:26 rac1.rajasekhar.com postmaster[10445]: 2021-03-15 19:52:26.856 +08 [10445] LOG:  redirecting log output to logging collector process
Mar 15 19:52:26 rac1.rajasekhar.com postmaster[10445]: 2021-03-15 19:52:26.856 +08 [10445] HINT:  Future log output will appear in directory "log".
Mar 15 19:52:26 rac1.rajasekhar.com systemd[1]: Started PostgreSQL 13 database server.
Mar 15 19:53:40 rac1.rajasekhar.com systemd[1]: Reloaded PostgreSQL 13 database server.
Mar 15 20:03:49 rac1.rajasekhar.com systemd[1]: Reloaded PostgreSQL 13 database server.
[root@rac1 ~]#

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
WhatsApp : +
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/