duplicate - pgrecm/RECM GitHub Wiki

Home - Top

DUPLICATE FULL|PARTIAL

This command allow you to restore a whole or partial PostgreSQL engine onto a different location.

Option/Qualifier

/name=”...” Name of the new cluster to restore/create
/directory=”” New PGDATA diectory. If the directory exist, it must be empty.
/port=nnnn Port number to use for the new cluster
/until=”DATE” Allow you to perform a Point in time recorery (PTR).
/rp=”RPNAME” Restore until a restore point name.
/lsn=”LSN” Restore until a given LSN
/uid="UID" UID of the full backup to use for restore.
/cid=”CID Cluster source to use (Default is currently connected).
/verbose Display more details.
/norevover Perform restore and stop before to launch the recovery process. This allow you to perform the recovery by yourself. Skip recovery imply no reindex if backup has been done with '/noindex' option.
/keepdata Rename directory to keep old folder.
/inclusive Recovery will stop just before the specified recovery target (recovery_target_inclusive is false).
/noninclusive Recovery will stop just after the specified recovery target (recovery_target_inclusive is true). (This is the default).
/db=”LIST” Specify the db to restore, or the db to exclude

Description

After the restore of the all the files, the configuration file 'PostgreSQL.conf' and 'pg_hba.conf' are overwritten by a more simple configuration during the recovery process.After this operation, the original configuration files are restored, and the engine restarted.

The date format is defined by the configuration item '/date_format'. The default is 'YYYY-MM-DD-HH'.
(See 'set config' command for more details)

The format of the objects to restore or exclude accet the following syntax : First character is '-' (minus sign). Object is excluded First character is '+' (plus sign), object is included Keyword contain '*' (asterisk), object contain a fixed and variable part

Example of syntax:
.../table=”test” Restore table 'test' from any database.
.../table=”test*” Restore all tables where the name start by 'test', on any database.
.../table=”-test*” Restore all tables except the name start by 'test', on any database.
.../db=”demo” Restore only the 'demo' database and all of it's objects
.../db=”-demo,-demo2” Restore all databases except 'demo' and 'demo2'

The restore/duplicate use the same directory as the one used at backup time.

If the source directory is not known from the host, you may use the 'set source/directory' command to change the source directory during the restore/duplicate.

Example

RECM> duplicate partial /dir="/tmp/data" /db="demo" /table="test*" /port=6666 
recm-inf: Restoring backup from UID '000161dda8543588e520' (TL 35, Version 12, WAL '1D/95000028')
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
Create link '/tmp/data/pg_tblspc/131219' with '/tmp/data/TBS0_6666'(rc=0 : 2)         
Create link '/tmp/data/pg_tblspc/255325' with '/tmp/data/TBS1_6666'(rc=0 : 2)         
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
100.00% ################################################################################
recm-inf: Recovery in progress (LSN '1D/96000060')
recm-inf: Recovery in progress (LSN '1D/A0000000')
recm-inf: Recovery ended at WAL '000000240000001D0000009F', LSN '1D/A0000000'
recm-inf: Database successfully restored.
recm-inf: Connect using Host:port: localhost:6666
NOTICE:  table "test_copy" has no indexes to reindex
RECM> exit 
Postgres@[~]# bin/psql -p6666 demo
psql (12.3)
Type "help" for help.

demo=# \l
                             List of databases
   Name    |  Owner   | Encoding  | Collate | Ctype |   Access privileges   
-----------+----------+-----------+---------+-------+-----------------------
 demo      | postgres | SQL_ASCII | C       | C     | 
 postgres  | postgres | SQL_ASCII | C       | C     | 
 template0 | postgres | SQL_ASCII | C       | C     | =c/postgres          +
           |          |           |         |       | postgres=CTc/postgres
 template1 | postgres | SQL_ASCII | C       | C     | =c/postgres          +
           |          |           |         |       | postgres=CTc/postgres
(4 rows)

demo=# \d
           List of relations
 Schema |   Name    | Type  |  Owner   
--------+-----------+-------+----------
 public | test      | table | postgres
 public | test_copy | table | postgres
(2 rows)
demo=# 

⚠️ **GitHub.com Fallback** ⚠️