Barman restoration

 


mkdir -p /database/edb/clone/as14

chown -R enterprisedb:enterprisedb /database


export PGDATA=/database/edb/clone/as14

export PGHOME=/usr/edb/as14

initdb -E UTF-8 — lc-collate='C' — lc-ctype='C' -D $PGDATA


/usr/edb/as14/bin/pg_ctl -D /database/edb/clone/as14 -l logfile status


barman list-backup dev-pgsql

barman recover --remote-ssh-command 'ssh enterprisedb@pg' \

        pg latest \

        /database/edb/clone/as14

or


barman recover dev-pgsql 20210224T150826 /backup/restored_db/pg12test_data/


OUTPUT:


-bash-4.2$ id

uid=986(enterprisedb) gid=980(enterprisedb) groups=980(enterprisedb) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023



-bash-4.2$ export PGDATA=/database/edb/clone/as14

-bash-4.2$ export PGHOME=/usr/edb/as14

-bash-4.2$ initdb -E UTF-8 — lc-collate='C' — lc-ctype='C' -D $PGDATA

initdb: too many command-line arguments (first is "—")

Try "initdb --help" for more information.

-bash-4.2$ initdb -E UTF-8 --lc-collate='C' --lc-ctype='C' -D $PGDATA

The files belonging to this database system will be owned by user "enterprisedb".

This user must also own the server process.


The database cluster will be initialized with locales

  COLLATE:  C

  CTYPE:    C

  MESSAGES: en_IN.UTF-8

  MONETARY: en_IN.UTF-8

  NUMERIC:  en_IN.UTF-8

  TIME:     en_IN.UTF-8

The default text search configuration will be set to "english".


fixing permissions on existing directory /database/edb/clone/as14 ... ok

creating subdirectories ... ok

selecting default max_connections ... 100

selecting default shared_buffers ... 32MB

creating configuration files ... ok

creating template1 database in /database/edb/clone/as14/base/1 ... ok

initializing pg_authid ... ok

initializing dependencies ... ok

creating system views ... ok

loading system objects' descriptions ... ok

creating collations ... ok

creating conversions ... ok

creating dictionaries ... ok

setting privileges on built-in objects ... ok

creating information schema ... ok

loading PL/pgSQL server-side language ... ok

vacuuming database template1 ... ok

copying template1 to template0 ... ok

copying template1 to postgres ... ok


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:


    postgres -D /database/edb/clone/as14

or

    pg_ctl -D /database/edb/clone/as14 -l logfile start


-bash-4.2$ 



################################################################

-bash-4.2$ /usr/edb/as14/bin/pg_ctl -D /database/edb/clone/as14 -l logfile status

pg_ctl: no server running

-bash-4.2$ 


################################################################


-bash-4.2$ barman list-backup dev-pgsql

dev-pgsql 20240227T130011 - Tue Feb 27 13:00:15 2024 - Size: 87.3 MiB - WAL Size: 0 B

dev-pgsql 20240227T125109 - Tue Feb 27 12:51:26 2024 - Size: 87.2 MiB - WAL Size: 83.3 KiB

-bash-4.2$ 


barman recover dev-pgsql --remote-ssh-command 'ssh enterprisedb@postonline' 20240227T125109 /database/edb/clone/as14



-bash-4.2$ id

uid=984(barman) gid=978(barman) groups=978(barman) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

-bash-4.2$ barman recover dev-pgsql --remote-ssh-command 'ssh enterprisedb@postonline' 20240227T125109 /database/edb/clone/as14

enterprisedb@postonline's password: 

enterprisedb@postonline's password: 

Starting remote restore for server dev-pgsql using backup 20240227T125109

Destination directory: /database/edb/clone/as14

Remote command: ssh enterprisedb@postonline

enterprisedb@postonline's password: 

enterprisedb@postonline's password: 

enterprisedb@postonline's password: 

Copying the base backup.

enterprisedb@postonline's password: 

enterprisedb@postonline's password: 

enterprisedb@postonline's password: 

enterprisedb@postonline's password: 

enterprisedb@postonline's password: 

enterprisedb@postonline's password: 

Copying required WAL segments.

enterprisedb@postonline's password: 

Generating archive status files

enterprisedb@postonline's password: 

enterprisedb@postonline's password: 

enterprisedb@postonline's password: 

Identify dangerous settings in destination directory.

enterprisedb@postonline's password: 


IMPORTANT

These settings have been modified to prevent data losses


postgresql.conf line 250: archive_command = false


Recovery completed (start time: 2024-03-02 12:42:58.828070+05:30, elapsed time: 1 minute, 5 seconds)

Your PostgreSQL server has been successfully prepared for recovery!

-bash-4.2$ 


#############################################################################


/usr/edb/as14/bin/pg_ctl -D /database/edb/clone/as14 -l logfile status


-bash-4.2$ id

uid=986(enterprisedb) gid=980(enterprisedb) groups=980(enterprisedb) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

-bash-4.2$ /usr/edb/as14/bin/pg_ctl -D /database/edb/clone/as14 -l logfile status

pg_ctl: no server running

-bash-4.2$ /usr/edb/as14/bin/pg_ctl -D /database/edb/clone/as14 -l logfile start

waiting for server to start.... done

server started

-bash-4.2$ /usr/edb/as14/bin/pg_ctl -D /database/edb/clone/as14 -l logfile status

pg_ctl: server is running (PID: 14445)

/usr/edb/as14/bin/edb-postgres "-D" "/database/edb/clone/as14"

-bash-4.2$ ps -ef|grep postgres

enterpr+ 14445     1  0 12:50 ?        00:00:00 /usr/edb/as14/bin/edb-postgres -D /database/edb/clone/as14

enterpr+ 14446 14445  0 12:50 ?        00:00:00 postgres: logger 

enterpr+ 14448 14445  0 12:50 ?        00:00:00 postgres: checkpointer 

enterpr+ 14449 14445  0 12:50 ?        00:00:00 postgres: background writer 

enterpr+ 14450 14445  0 12:50 ?        00:00:00 postgres: walwriter 

enterpr+ 14451 14445  0 12:50 ?        00:00:00 postgres: autovacuum launcher 

enterpr+ 14452 14445  0 12:50 ?        00:00:00 postgres: archiver 

enterpr+ 14453 14445  0 12:50 ?        00:00:00 postgres: stats collector 

enterpr+ 14454 14445  0 12:50 ?        00:00:00 postgres: dbms_aq launcher 

enterpr+ 14455 14445  0 12:50 ?        00:00:00 postgres: logical replication launcher 

enterpr+ 14483 13230  0 12:51 pts/4    00:00:00 grep --color=auto postgres


#############################################################################


/usr/edb/as14/bin/psql -d postgres -U enterprisedb


-bash-4.2$ /usr/edb/as14/bin/psql -d postgres -U enterprisedb

psql (14.11.0)

Type "help" for help.


postgres=# \l

                                           List of databases

   Name    |    Owner     | Encoding |   Collate   |    Ctype    | ICU |       Access privileges       

-----------+--------------+----------+-------------+-------------+-----+-------------------------------

 dev       | test         | UTF8     | C           | C           |     | 

 edb       | enterprisedb | UTF8     | C           | C           |     | 

 postgres  | enterprisedb | UTF8     | C           | C           |     | 

 sit       | test         | UTF8     | en_US.UTF-8 | en_US.UTF-8 |     | 

 template0 | enterprisedb | UTF8     | C           | C           |     | =c/enterprisedb              +

           |              |          |             |             |     | enterprisedb=CTc/enterprisedb

 template1 | enterprisedb | UTF8     | C           | C           |     | =c/enterprisedb              +

           |              |          |             |             |     | enterprisedb=CTc/enterprisedb

(6 rows)


postgres=# \du

                                         List of roles

       Role name       |                         Attributes                         | Member of 

-----------------------+------------------------------------------------------------+-----------

 aq_administrator_role | No inheritance, Cannot login                              +| {}

                       | Profile default                                            | 

 barman                | Superuser                                                 +| {}

                       | Profile default                                            | 

 enterprisedb          | Superuser, Create role, Create DB, Replication, Bypass RLS+| {}

                       | Profile default                                            | 

 test                  | Superuser                                                 +| {}

                       | Profile default                                            | 


postgres=# \c test

connection to server on socket "/tmp/.s.PGSQL.5444" failed: FATAL:  database "test" does not exist

Previous connection kept

postgres=# \c dev

You are now connected to database "dev" as user "enterprisedb".

dev=# \dt

            List of relations

 Schema |   Name   | Type  |    Owner     

--------+----------+-------+--------------

 public | employee | table | enterprisedb

(1 row)


dev=# \dt+

                                         List of relations

 Schema |   Name   | Type  |    Owner     | Persistence | Access method |    Size    | Description 

--------+----------+-------+--------------+-------------+---------------+------------+-------------

 public | employee | table | enterprisedb | permanent   | heap          | 8192 bytes | 

(1 row)


dev=# 


dev=# select * from employee;

 emp_id | first_name | last_name | gender |     birthdate      |         email          | salary 

--------+------------+-----------+--------+--------------------+------------------------+--------

      1 | Annie      | Smith     | F      | 09-JAN-88 00:00:00 | test@email.com          |   5000

      3 | May        | Kaasman   | M      | 09-JUL-94 00:00:00 | testing@gmail.com |       

      4 | Charlton   | Duran     | M      | 02-OCT-10 00:00:00 |                        |       

(3 rows)


dev=# 




















Comments

Popular Posts

AWR Report Analysis

Goldengate 19c Installation with issue resolution

Oracle 11g Physical Standy Setup

Oracle 12c 2-node RAC setup in VMware Player 15 -- Part01

Oracle to Postgres

Execution_Explain Plan

Active Session History Analysis

General Queries

Fragmentation & Re-organisation

OEM patches & vulnerabilities